我想使用python脚本显示我们域中的所有本地管理员。在
我的代码:
for line in open(anfangsrechner,"r"):
zeile = line.strip()
command ='\\\\' +zeile+ ' -i' ' net' ' localgroup' ' Administratoren'
abfrage = subprocess.Popen(['PsExec.exe ',command,],stdin=subprocess.PIPE,
stdout=subprocess.PIPE, )
# print (abfrage)
while True:
line = abfrage.communicate()
if not line:
break
print (line)
但我只能从psexec
命令得到:
我没有得到全部输出。有人知道我该怎么修吗?在
您将参数作为长字符串而不是列表传递。在
快速修复将使用
shell=True
:正确的方法是创建一个参数列表并传递它。在
引用the documentation:
相关问题 更多 >
编程相关推荐