13

Running a remote batch file using psexec through Jenkins fails. Running the same batch file using psexec from the slave directly works without a charm.

Let me provide some more information. Jenkins and its slave are in a separate domain than our target machine.

When I run the batch file like this:

"D:\Temp\PsTools\PsExec.exe" \\<targetmachine> -u <targetdomain\targetdomainuser> -p <pwd> -accepteula  "d:\temp\remotescript.bat" arg1 arg2

directly from the slave (Remote Desktop taking over the machine and opening a command prompt) this works perfectly.

When entering it in a windows batch build step in Jenkins there is no visible output and I just see a spinner but nothing happens anymore and the build hangs queuing any other build creating a massive backlog. Apparently I get a failure audit where my Jenkins user tries to logon to the target machine however I specified a domain user with admin rights on the target machine (a domain user for the domain of the target machine).

Does anyone have any idea why the user tries to logon with any other credentials than the ones provided and why this works running it from the Jenkins-slave directly?

Or any other way of achieving this (running a batch file on the remote machine) is more than welcome.

4 Answers 4

7

PAExec is a functional clone of PSExec and lets us see the output via Jenkins etc.

http://www.poweradmin.com/paexec/

XCmd is what we used at HP but for some reason it is not working at my current gig.

I don't know when PAExec appeared but it seems an ideal solution. Soon after discovering it (today) I nailed an intermittent problem with a very long/ involved Jenkins Deployment Pipeline.

3
  • 2
    Paul, thanks you very much! I had same issue, that invoking psexec via Jenkins returns only 80 chars to stdout. PAExec works perfect. I see all stdout in Jenkins output!
    – akozin
    Apr 8, 2015 at 6:54
  • 1
    @Guillaume~ Thanks for posting this question ! Found it useful after 3 years. Paul and akozin thanks, I was trying this for over a fortnight ! I don't know how I shall thank you on this.
    – Hunterr
    May 13, 2016 at 10:28
  • 1
    Paul, thanks so much...I was trying this since so many days and with your answer I was through in 2 minutes... saved my life..:D
    – Stack_IQ
    May 17, 2017 at 8:55
6

This is a notorious issue with psexec:

http://forum.sysinternals.com/psexec-always-hangs-when-run-from-java_topic5013.html

Program output lost when passed through PsExec

You can try with xCmd: http://feldkir.ch/xcmd.htm (it will not work against localhost)

2
  • Localhost is no concern. I had a little trouble on getting the xCmd file due to the false virusalert, but got it running. I need to investigate one small error probably due to passing my arguments. Feb 26, 2013 at 21:59
  • 2
    I had a trouble with xCmd when connected to 64-bit servers: "Couldn't start remote service Error:2 - The system cannot find the file specified." Easy way to fix is copying xCmdSvc.exe from C:\Windows\System32 to C:\Windows\SysWOW64. Jan 21, 2014 at 7:12
3

Try this , this will work

"D:\Temp\PsTools\PsExec.exe" \\\\remoteMachine -u username -p password /accepteula -h cmd /c "C:\remotescript.bat"
-1

try couple things...

  1. add parameter option 0 after the accepteula in your command that should kills any existing psexec process which is hung up and start processing your psexec

  2. verify the machine for 32-bit or 64-bit..

    for 64-bit the psexec is searched in C:\Windows\system32
    for 32-bit the psexec is searched in C:\Windows\SysWOW64

in jenkins job you can set msbuild version to 64 BIT or 32 BIT accordingly and it should work as expected.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.