【发布时间】:2019-11-06 21:42:05
【问题描述】:
我正在测试一个 PS 脚本,该脚本将被放入 win10 右键单击上下文菜单中,该脚本仅接受路径信息,然后将其回显到我的终端窗口。
注册表项如下:
Computer\HKEY_CLASSES_ROOT\*\shell\MyScript\command
@="powershell.exe -window hidden -command .'\"G:\\path to my script\\MyScript.ps1\"' '%V'"
脚本只是$args。
对于大多数常规路径,它运行良好。现在我遇到了文件名包含一个单引号的情况,例如:"D:\John's file.txt"。
它会抛出一个错误:
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
我应该怎么做才能解决这个问题?
【问题讨论】:
-
对不起,我错过了(这就是我刚刚删除我的 cmets 的原因)。无论如何,在 stackoverflow 上有很多类似的问题和答案,例如:stackoverflow.com/questions/20958388/…
标签: windows powershell registry contextmenu