Search code examples
batch-filejenkinspsexec

psexec exit with process id in jenkins


In Jenkins, while using psexec to run a batch file

psexec \\workstation007 -u user -p Pa55w0rd -accepteula -i 2 -h cmd.exe /k "abc.bat"

starts a new prompt in remote machine and loops in spinner rotating in console log

psexec \\workstation007 -u user -p Pa55w0rd -accepteula -i 2 -h -d cmd.exe /k "abc.bat" 

starts new prompt but exits with process id in console log.

But I want to display everything that is displayed on cmd prompt in the console log itself. The batch file has other commands for execution. I assume that as the commands are not completely executed, the -d wont wait for process to complete,so it returns the process id. How should I handle this situation.


Solution

  • With much of R&D,

    The solution for this was paexec. While psexec supported 80 characters, the functional clone paexec supported whole of it. Syntax I used:

    paexec \\remote_machine -u user -p password /accepteula -h cmd /c "D:\abc.bat" arg1 arg2