批处理文件中的 Powershell 命令未按预期工作
Powershell command from batch file not working as expected
我是 运行 批处理脚本,但我收到一条错误消息,指出
-command is not recognized as internal or external command, operable program or batch file
我不明白为什么。我还查看了我的环境变量路径。看起来没问题。
下面是脚本
@echo off
set PWSH = %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
%PWSH% -command $input ^| %1\post-commit-jenkins.ps1 %1 %2
pause
if errorlevel 1 exit %errorlevel%
请提供您的意见和可能的解决方案。
@echo off
set "PWSH=%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
%PWSH% -command $input ^| %1\post-commit-jenkins.ps1 %1 %2
pause
if errorlevel 1 exit %errorlevel%
设置 otherwise 时删除 space 因为它将成为变量名称的一部分(不是我不知道 %1 和 %2 参数是什么所以我不知道该怎么做期待更多)
我是 运行 批处理脚本,但我收到一条错误消息,指出
-command is not recognized as internal or external command, operable program or batch file
我不明白为什么。我还查看了我的环境变量路径。看起来没问题。
下面是脚本
@echo off
set PWSH = %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
%PWSH% -command $input ^| %1\post-commit-jenkins.ps1 %1 %2
pause
if errorlevel 1 exit %errorlevel%
请提供您的意见和可能的解决方案。
@echo off
set "PWSH=%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
%PWSH% -command $input ^| %1\post-commit-jenkins.ps1 %1 %2
pause
if errorlevel 1 exit %errorlevel%
设置 otherwise 时删除 space 因为它将成为变量名称的一部分(不是我不知道 %1 和 %2 参数是什么所以我不知道该怎么做期待更多)