在'

问题描述 投票:0回答:1

我试图与参数一起运行在命令行的PowerShell脚本,但它始终与下面的错误而失败。任何人都可以帮忙吗?

cmd /c "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\start.ps1 -settings_override_xml /"<?xml version=/'1.0/'?><Settings><Keys>243</Keys></Settings>/""

错误:

< was unexpected at this time
powershell command command-line-arguments command-prompt powershell-v1.0
1个回答
0
投票

逃生与反引号中间的双引号。

cmd /c "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\start.ps1 -settings_override_xml /`"<?xml version=/'1.0/'?><Settings><Keys>243</Keys></Settings>/`""

编辑:解释,有人读你的原始命令为:

用命令启动命令提示符:

cmd /c "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\start.ps1 -settings_override_xml /"

然后导入以下作为参数或输入该命令:

<?xml version=/'1.0/'?><Settings><Keys>243</Keys></Settings>/""

嗯,你说得对,它的示数的<这是一个保留字符,和我打赌它会出错ON>为好。逃生者,它应该工作。

cmd /c 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\start.ps1 -settings_override_xml /"`<?xml version=/''1.0/''?`>`<Settings`>`<Keys`>243`</Keys`>`</Settings`>/"'

经测试,由于我的机器上工作,没有错误给出。

© www.soinside.com 2019 - 2024. All rights reserved.