我正在尝试在远程服务器上运行批处理脚本。所以我正在编写这样的代码。
import subprocess
subprocess.call("psExec \\\\11.456.787.8 -u {} -p {} C:\\basicfolder\\".format('user','pwd')+'run_1523448627.15.bat',shell=True)
错误是
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Couldn't access 11.456.787.8:
Access is denied.
5
但是我收到了拒绝访问的错误。当我手动尝试psexec命令时,它正在连接并执行。但在python中它抛出错误
答案 0 :(得分:0)
我怀疑用户名或密码中未显示的内容未被命令行正确转义。您应该使用实际参数重写命令:
import subprocess
username = "foo"
password = "whatever"
subprocess.call(["psExec","/accepteula",r"\\11.456.787.8","-u",username,"-p",password,"whateverfile.bat'])
这样:
shell=True
/accepteula
不再有新的个人资料弹出窗口(奖金)