Powershell Start-Process 命令参数转义

Powershell Start-Process 命令参数转义

我尝试在 powershell 会话中打开提升权限的 powershell。此方法有效:

powershell -NoExit -Command "Start-Process PowerShell -ArgumentList @('-NoExit','-NoProfile') -Verb RunAs"

这不会:

powershell -NoExit -Command "Start-Process PowerShell -ArgumentList @(`"-NoExit`",`"-NoProfile`") -Verb RunAs"

错误说:

In Zeile:1 Zeichen:49
+ Start-Process PowerShell -ArgumentList @(-NoExit,-NoProfile) -Verb Ru ...
+                                                 ~
Argument in der Parameterliste fehlt.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArgument
+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingArgument

所以引文不知为何就丢失了。为什么呢?

相关内容