【发布时间】:2018-02-13 18:51:56
【问题描述】:
以下命令在 PowerShell 控制台中成功运行,但未在 cmd 提示符下运行。我不知道如何翻译它。
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -Command '&{C:\Foo\MyScript.ps1 -InputPath ''C:\Foo'' -OutputPath ''C:\Foo\output'' -XmlPath ''C:\Foo\input\FrontDoor.xml'' -AssemblyPaths ''C:\Foo\input\file1.dll'',''C:\Foo\input\file2.dll'',''C:\Foo\input\file3.dll'' -Version 3 -Format json}; EXIT $LASTEXITCODE'
在 cmd 提示符下运行时,出现以下错误。
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
我尝试了很多方法让它工作,但没有成功。
【问题讨论】:
-
要帮助解决引用问题,请查看
-EncodedCommandswitch。 -
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -Command "&{C:\Foo\MyScript.ps1 -InputPath 'C:\Foo' -OutputPath 'C:\Foo\output' -XmlPath 'C:\Foo\input\FrontDoor.xml' -AssemblyPaths 'C:\Foo\input\file1.dll','C:\Foo\input\file2.dll','C:\Foo\input\file3.dll' -Version 3 -Format json}; EXIT $LASTEXITCODE" -
为什么需要在 cmd.exe 提示符下运行它?只需在 PowerShell 中运行您想要的命令即可。
-
@Bill_Stewart,我没有那么方便。 vsts-task-lib 最终在云中的 Windows 代理上运行命令。
-
This answer 很可能会解决您的问题
标签: powershell cmd