Я пытаюсь создать сценарий powershell, который создает ярлык на рабочем столе для устройства UPnP. Я успешно использовал $ WScriptShell.CreateShortcut(), чтобы создать ярлык для файла .exe или http-адрес, но я не понимаю, как указать адрес устройства. Однако я могу создать ярлык вручную, щелкнув правой кнопкой мыши на устройствах в проводнике Windows, но как мне сделать то же самое программно?Powershell, ярлык для устройства UPnP
0
A
ответ
0
Создание пользовательского ярлыка с 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()
Alternate Примером для удаления 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 и указана в списке сетевых/других устройств/cameraname. Он использует UPnP для идентификации себя как uuid: Upnp-BasicDevice-1_0-. –
MathiasS