不能将 subprocess.call 与 psexec.exe 一起使用

Cannot use subprocess.call with psexec.exe

我正在尝试使用 psexec 来 运行 远程 PC 上的脚本,但是当我使用 subprocess.call 时,我得到 WindowsError: [Error 2] The system cannot find the file specified

我已经下载了 PsExec,解压并将下载的所有内容放入

C:\Windows\System32\ 我的测试代码是:

from subprocess import call

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

我只是想看看我是否能看到命令正常工作,但运气不好。

当我尝试 call(['C:\Windows\System32\PsExec.exe'], shell=True) 我得到

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

当我在该文件夹中尝试另一个程序时,它似乎可以正常工作...有什么东西是我立即遗漏的吗?

你可以试试这个:

from subprocess import call

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

希望它能在您的系统上运行!