使用winrm远程操作window的命令窗口,前提关闭远程机子的防火墙
# -*- coding:UTF-8 -*- import winrm ip = 'xxx.xxx.xxx.xxx' #远程机器ip userName = 'xxx' #用户名 password = 'xxx' #密码 wintest = winrm.Session(ip, auth=(userName, password)) ret = wintest.run_cmd('执行命令') print( bytes.decode(ret.std_out))