小编Joe*_*Joe的帖子

使用Powershell创建Windows快捷方式,目标路径中的空格问题

简短又甜蜜,我在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"

为什么?!?!?!?!

powershell shortcuts windows-7

4
推荐指数
1
解决办法
2707
查看次数

标签 统计

powershell ×1

shortcuts ×1

windows-7 ×1