1

I am running a batch script, but I get an error stating that

-command is not recognized as internal or external command, operable program or batch file

I am not able to understand why. I also looked at my environmental variable path. That looks to be fine.

Below is the Script

@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%  

Please provide your opinion and possible solution .

3
  • 4
    npocmaka already provided the solution, but to explain why: %PWSH% is empty, because the variable you defined is %PWSH %. Remove Echo off to watch... Commented Jan 3, 2018 at 12:57
  • It may help were you to explain what you expect %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -command $input ^| %1\post-commit-jenkins.ps1 %1 %2 to do! Commented Jan 3, 2018 at 13:17
  • Very doubtful that you are using Powershell version 1 these days. Commented Jan 3, 2018 at 14:52

1 Answer 1

1
@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% 

Remove the space when you are setting a otherwise because it will be part of the variable name (not I have no idea what are the %1 and %2 arguments so I don't know what to expect further )

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.