I'm running into an issue where a 'Execute Windows batch command' build step is failing to find PsExec. To help narrow down the issue I've created a test project with the following build step:
C:\Windows\System32\PsExec /?
PsExec /?
C:\users\admin\Desktop\PsExec /?
Here are the results:
Building in workspace C:\SoveraHIMDEV-10.2.1
[SoveraHIMDEV-10.2.1] $ cmd /c call C:\Users\admin\AppData\Local\Temp\hudson9054484821341580808.bat
C:\SoveraHIMDEV-10.2.1>C:\Windows\System32\PsExec /?
'C:\Windows\System32\PsExec' is not recognized as an internal or external command,
operable program or batch file.
C:\SoveraHIMDEV-10.2.1>PsExec /?
'PsExec' is not recognized as an internal or external command,
operable program or batch file.
C:\SoveraHIMDEV-10.2.1>C:\users\admin\Desktop\PsExec /?
PsExec v2.0 - Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals - www.sysinternals.com
PsExec executes a program on a remote system, where remotely executed console
applications execute interactively.
As you can see, it runs from an absolute path to the desktop, but does not run when just using 'PsExec' or 'C:\Windows\System32\PsExec'. However, all three of these examples execute from the command line correctly.
I've added the PsExec executable to the Jenkins machine's C:\Windows\System32 folder. PsExec works when executing 'PsExec /?' from the command line, and Jenkins shows 'C:\Windows\System32' in its path configurations.
java.library.path:
C:\Program Files (x86)\Jenkins\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\app\admin\product\11.1.0\client_1\bin;C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\apache-maven-3.1.1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Git\cmd;.
Environment Path:
C:\app\admin\product\11.1.0\client_1\bin;C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\apache-maven-3.1.1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Git\cmd
I'm able to run other executables from 'C:\Windows\System32'
What am I missing that stops Jenkins from finding PsExec?
It might be an issue of file system virtualization.
When you copy a file to C:\Windows\System32
it might only be visible for you, not for Jenkins. Copy it to the SysWOW64
folder instead.