【问题标题】:Cannot use subprocess.call with psexec.exe无法将 subprocess.call 与 psexec.exe 一起使用
【发布时间】:2015-10-08 08:34:19
【问题描述】:

我正在尝试使用 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.

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

【问题讨论】:

  • “System32”在 32 位进程中被重定向到“SysWOW64”。在 Windows 7+ 中,您可以将真正的“System32”作为“SysNative”访问。
  • 哦,谢谢,我只是通过在 C:\PsTools 重新安装它来解决它,但感谢您将来参考。

标签: python windows python-2.7 subprocess psexec


【解决方案1】:

你可以试试这个:

from subprocess import call

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

我希望它可以在您的系统上运行!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-26
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2017-03-07
    • 2013-07-30
    • 2014-11-23
    • 2020-06-05
    相关资源
    最近更新 更多