我正在尝试使用批处理文件中的-command参数调用powershell脚本。powershell脚本接受可能包含空格的参数。该命令无法接受带空格的参数。
这就是批处理文件。
@echo off
set arg1=%*
call powershell.exe -ExecutionPolicy Bypass -command ".\build.ps1 %arg1%; exit $LASTEXITCODE"
exit /b %ERRORLEVEL%批处理文件的名称是- .\build.bat '-testToolPath=as sdaf'
我使用-command而不是-file只是为了返回LASTEXITCODE
发布于 2018-05-22 23:29:48
你有没有尝试过使用转义的双二进制代码?
call powershell -ExecutionPolicy Bypass -command ".\build.ps1 ^"%arg1%^"; exit $LASTEXITCODE"也许你必须在下面之前删除其他引号:
set "arg1=%arg1:'=%"https://stackoverflow.com/questions/50464085
复制相似问题