我正在尝试从命令行运行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
发布于 2014-07-31 08:43:28
用反勾号避开中间的双引号。
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>/""
嗯,你说得对,它是错误的<,这是一个保留字符,我打赌它也会出错。逃离那些,它就会起作用。
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`>/"'
在没有错误的情况下在我的机器上工作。
https://stackoverflow.com/questions/25064408
复制