AWS Thinkbox Discussion Forums

'|' OR operator giving out error when used in command string in SendRemoteCommand()

PFL below example code to execute at remote pc.When i run this, it gives me error, cannot recognize the command “find”.What ever comes after this symbol ‘|’ will be shown as error in console. I see it is because of ‘|’ or operator in the command which is giving me the error. I tried to escape using ‘|’ but no luck. can someone please let me know how to resolve this issue.

codeToRun =r"Execute cmd /C tasklist /FI “IMAGENAME eq myapp.exe” 2>NUL | find /I /N “myapp.exe”>NUL & if “%ERRORLEVEL%”==“0” echo Program is running"

SlaveUtils.SendRemoteCommand(slaveName,codeToRun )

Privacy | Site terms | Cookie preferences