zoukankan      html  css  js  c++  java
  • Python远程连接Windows,并调用Windows命令(类似于paramiko)

    import winrm
    
    win2012 = winrm.Session('http://192.168.0.19:5985/wsman',auth=('wt','635870838'))
    
    
    r = win2012.run_cmd('D: &'
                        ' cd python &'
                        ' type s.txt &'
     ' net stop iphlpsvc
    ') # net stop iphlpsvc 是关闭iphlpsvc服务 print(r.std_out.decode()) # 打印获取到的信息 print(r.std_err) #打印错误信息 注意:需要在被控机上开启以下服务: 针对winrm service 进行基础配置: winrm quickconfig 查看winrm service listener: winrm e winrm/config/listener 为winrm service 配置auth: winrm set winrm/config/service/auth @{Basic="true"} 为winrm service 配置加密方式为允许非加密: winrm set winrm/config/service @{AllowUnencrypted="true"}
  • 相关阅读:
    DockerAPI版本不匹配的问题
    Linux文件系统
    队列

    多维数组
    字符串
    线性表
    ARM编辑、编译工具
    南京IT公司
    数据结构:用单链表实现的队列(2)
  • 原文地址:https://www.cnblogs.com/wt11/p/6757356.html
Copyright © 2011-2022 走看看