Joe*_*Joe 4 powershell shortcuts windows-7
简短又甜蜜,我在PS中制作快捷方式,只要目标路径中没有空格,快捷方式就可以正常工作.一旦Target中有空格,快捷方式目标就会用双引号括起来,因此不起作用......下面是非工作代码.如果你要删除它会正确的空间(除了它在那一点上没有指向EXE的事实).基本上它不会将目标包装在引号中.
$shell = New-Object -ComObject WScript.Shell
$shortcutX = $shell.CreateShortcut("C:\Short.lnk")
$shortcutX.TargetPath = "C:\apps\application --switch"
$shortcutX.Save()
Run Code Online (Sandbox Code Playgroud)
TL; DR:
作品.
$ shortcutX.TargetPath ="C:\ apps\application"
不行!
$ shortcutX.TargetPath ="C:\ apps\application --switch"
为什么?!?!?!?!
来自MSDN:
此属性仅适用于快捷方式的目标路径.
您可以在Argument属性中为快捷方式添加参数.
$shortcutX.Arguments = "-- switch"
Run Code Online (Sandbox Code Playgroud)
在我的盒子(Windows 7 Pro)上,我可以使用具有空格的路径目标来创建快捷方式.