【问题标题】:Powershell, shortcut to UPnP devicePowershell,UPnP 设备的快捷方式
【发布时间】:2017-01-27 11:47:41
【问题描述】:

我正在尝试创建用于创建 UPnP 设备的桌面快捷方式的 powershell 脚本。我已成功使用 $WScriptShell.CreateShortcut() 创建 .exe 文件或 http 地址的快捷方式,但我不明白如何指定设备的地址。但是,我可以通过右键单击 Windows 资源管理器中的设备来手动创建快捷方式,但我如何以编程方式执行相同操作?

【问题讨论】:

    标签: windows powershell upnp


    【解决方案1】:

    使用 PS 创建自定义快捷方式:

    # Quick shortcut creation script
    
    # This if the variable that will hold the computer name of your target device
    $computer = "The Computer Name" 
    # This command will create the shortcut object
    $WshShell = New-Object -ComObject WScript.Shell
    # This is where the shortcut will be created
    $Shortcut = $WshShell.CreateShortcut("\\$computer\C$\Users\Public\Desktop\SuperAwesomeness.lnk")
    # This is the program the shortcut will open
    $Shortcut.TargetPath = "C:\Program Files (x86)\Internet Explorer\iexplore.exe"
    # This is the icon location that the shortcut will use
    $Shortcut.IconLocation = "C:\AwesomeIcon.ico,0"
    # This is any extra parameters that the shortcut may have. For example, opening to a google.com when internet explorer opens
    $Shortcut.Arguments = "google.com"
    # This command will save all the modifications to the newly created shortcut.
    $Shortcut.Save()
    

    替代示例用于移除 USB:

    $AppLocation = "C:\Windows\System32\rundll32.exe"
    $WshShell = New-Object -ComObject WScript.Shell
    $Shortcut = $WshShell.CreateShortcut("$Home\Desktop\USB Hardware.lnk")
    $Shortcut.TargetPath = $AppLocation
    $Shortcut.Arguments ="shell32.dll,Control_RunDLL hotplug.dll"
    $Shortcut.IconLocation = "hotplug.dll,0"
    $Shortcut.Description ="Device Removal"
    $Shortcut.WorkingDirectory ="C:\Windows\System32"
    $Shortcut.Save()
    

    这里是参考链接:Custom Shortcut with PS

    【讨论】:

    • 感谢您的回答,但我已经知道如何创建文件或网页的简单快捷方式。我的主要问题是指定网络设备的路径。就我而言,我想要一个网络摄像头的快捷方式。摄像头在 Windows 中被发现并列在网络/其他设备/摄像头名称下。它使用 UPnP 将自己标识为 uuid:Upnp-BasicDevice-1_0-.
    猜你喜欢
    • 2014-05-12
    • 2019-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 2019-02-27
    相关资源
    最近更新 更多