![psexec could not start cmd c psexec could not start cmd c](https://www.cyberciti.biz/media/new/faq/2009/04/A-few-ways-to-execute-commands-remotely-using-SSH-on-macos-unix-bsd-system.png)
An ampersand at end of a shell script line is interpreted only by Unix/Linux/Mac shell script interpreters as instruction to run the executable detached in background. I recommend reading also the Microsoft documentation pages WOW64 Implementation Details and Registry Keys Affected by WOW64 to get knowledge on how 32-bit Windows emulation works on 64-bit Windows.Ī minor issue is appending & at end of the Windows command line. But if exist %SystemRoot%Sysnativecmd.exe can be used in a batch file to find out if the batch file is processed by 32-bit Windows command processor on a 64-bit Windows because of the condition evaluates to true in this use case. For that reason it is not possible to use in a batch file if exist %SystemRoot%Sysnative or if exist %SystemRoot%Sysnative as both conditions evaluate always to false. The file system does not contain an entry Sysnative in directory C:Windows. Please note that Sysnative is neither a directory nor a symbolic link or hard link. The special redirecting Sysnative exists only for 32-bit applications executed in 32-bit environment.
#Psexec could not start cmd c code
$args = '\\server -i -u "****" -p "****" "C:\directory\sub\test.bat"' Įxec('C:\Windows\Sysnative\SysinternalsSuite\PsExec.exe '.$args.) ģ2-bit python.exe runs with this code the 32-bit executable PsExec.exe in subdirectory SysinternalsSuite of 64-bit Windows system directory with the appropriate arguments.
![psexec could not start cmd c psexec could not start cmd c](https://www.alfintechcomputer.com/wp-content/uploads/2020/10/Type-PsExec-location-addressPsExec.exe-sid-cwindowssystem32cmd.exe-and-press-Enter.jpg)
It would be enough to use in Python script: Well, starting cmd.exe to run a batch file which contains only one command line to run psexec.exe with wrong path for 32-bit environment is not needed at all. 32-bit cmd fails to find C:WindowsSysWOW64SysinternalsSuitePsExec.exe and so psexec.exe is not executed at all. For that reason is started with just cmd in the Python script %SystemRoot%SysWOW64cmd.exe which is the 32-bit version of Windows command processor. %SystemRoot%SysWOW64 contains the 32-bit system executables, but not the directory SysinternalsSuite with file PsExec.exe. The usage of %SystemRoot%System32, which is usually expanded to C:WindowsSystem32, in 32-bit environment results in a redirection by Windows File System Redirector to %SystemRoot%SysWOW64 respectively expanded C:WindowsSysWOW64. The directory %SystemRoot%System32 is for 64-bit applications executed in 64-bit environment on 64-bit Windows. That was no good decision and cause the issue here.
#Psexec could not start cmd c install
The main problem is the decision to install the Sysinternals Suite into a subdirectory of %SystemRoot%System32.