![](/img/trans.png)
[英]Use PowerShell to unpin Taskbar shortcut depending on shortcut Target Path
[英]Powershell to create shortcut with quoted target path
我尝试通过 PowerShell 脚本创建快捷方式,并将以下值作为目标:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& '"C:\Program Files\Test\script.ps1"'"
这是我现有的脚本,它可以工作,但我无法根据需要在其中获取目标路径。
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("C:\Program Files\Test\test.lnk")
$Shortcut.TargetPath =
$Shortcut.WorkingDirectory = "C:\Program Files\Test\tool"
$Shortcut.Save()
我希望有一个人可以帮助我。
编辑;)我认为这就是你想要的:
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("C:\Program Files\Test\test.lnk")
$Shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$Shortcut.Arguments = "-Command `"& 'C:\Program Files\Test\script.ps1'`""
$Shortcut.WorkingDirectory = "C:\Program Files\Test\tool"
$Shortcut.Save()
因为这是一个脚本而不是命令,你也可以更喜欢
$Shortcut.Arguments = "-File 'C:\Program Files\Test\script.ps1'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.