Python远程操控电脑的CMD
Python远程操控电脑的CMD
# -*- coding: UTF-8 -*-
import winrm
# r = s.run_cmd('cd /d d: & dir')
# 链接服务器 需要在服务器端开启WINRM服务,具体如何开启百度
s = winrm.Session('http://写你的ip:5985/wsman', auth=('写登入用户', '写登入密码'))
# 查看备份是否OK
def shg_erp():
r = s.run_cmd('if exist "D:\ERPbeifen\BSERP3_backup_'
'%date:~0,4%_%date:~5,2%_%date:~8,2%*.bak"'
' (echo 1) else (echo 0)')
return r.std_out.strip()