Search code examples
pythonwindowspython-2.7subprocesspsexec

Cannot use subprocess.call with psexec.exe


I'm trying to use psexec to run a script on remote PCs but when I use subprocess.call I get WindowsError: [Error 2] The system cannot find the file specified

I have downloaded PsExec, unzipped and put all contents from the download in

C:\Windows\System32\ and my test code is:

from subprocess import call

call(['C:\\Windows\\System32\\PsExec.exe'])

I just wanted to see if i could see the command working, but no luck.

When I try call(['C:\\Windows\\System32\\PsExec.exe'], shell=True) I get

'C:\Windows\System32\PsExec.exe' is not recognized as an internal or external command, operable program or batch file.

When I try another propgram in that folder it seems to work... Is there something I'm immediatly missing?


Solution

  • you can try this:

    from subprocess import call
    
    call(['C:\\Windows\\SysNative\\PsExec.exe'],shell=True)
    

    i hope it's work on your system!