# PyWinOS
The cross-platform tool to work with remote and local Windows OS.
PyWinOS uses the Windows Remote Manager (WinRM) service. It can establish connection to a remote server based on Windows OS and execute commands:
- PowerShell
- Command line
- WMI.
It can execute commands locally using subprocess and command-line too.
For more information on WinRM, please visit [Microsoft’s WinRM site](https://docs.microsoft.com/en-us/windows/win32/winrm/portal?redirectedfrom=MSDN)
It based on [pywinrm](https://pypi.org/project/pywinrm/).
PyWinOS returns object with exit code, sent command, stdout/sdtderr response.
## Installation
For most users, the recommended method to install is via pip:
```cmd
pip install PyWinOS
```
## Import
```python
from pywinos import WinOSClient
```
---
## Usage (remote)
#### PowerShell:
```python
from pywinos import WinOSClient
tool = WinOSClient(host='172.16.0.126', username='administrator', password='rds123RDS', logger_enabled=True)
response = tool.run_cmd('$PSVersionTable.PSVersion')
print(response)
# ResponseParser(response=(0, 'Major Minor Build Revision\r\n----- ----- ----- --------\r\n5 1 17763 592', None, '$PSVersionTable.PSVersion'))
print(response.exited) # 0
print(response.stdout)
# Major Minor Build Revision
# ----- ----- ----- --------
# 5 1 17763 592
print(response.stderr) # None
print(response.ok) # True
```
#### Command line:
```python
from pywinos import WinOSClient
tool = WinOSClient('172.16.0.126', 'administrator', 'P@ssw0rd', logger_enabled=False)
response = tool.run_cmd('whoami')
print(response) # <Response code 0, out "b'\r\nMajor Minor Buil'", err "b''">
print(response.exited) # 0
print(response.stdout) # test-vm1\administrator
print(response.stderr) # None
print(response.ok) # True
```
## Usage (local)
#### Command line:
```python
from pywinos import WinOSClient
tool = WinOSClient(logger_enabled=False)
# tool = WinOSClient(host='', logger_enabled=False)
# tool = WinOSClient(host='localhost', logger_enabled=False)
# tool = WinOSClient(host='127.0.0.1', logger_enabled=False)
response = tool.run_cmd('whoami')
print(response) # (0, b'my_pc\\bobby\r\n', b'')
print(response.exited) # 0
print(response.stdout) # my_pc\bobby
print(response.stderr) # None
print(response.ok) # True
PyPI 官网下载 | pywinos-1.0.1.tar.gz
版权申诉
93 浏览量
2022-02-10
22:16:10
上传
评论
收藏 5KB GZ 举报
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
最新资源
- 数据库管理工具:dbeaver-ce-23.2.2-stable.x86-64.rpm
- 数据库管理工具:dbeaver-ce-23.2.2-macos-x86-64.dmg
- 数据库管理工具:dbeaver-ce-23.2.2-macos-aarch64.dmg
- 数据库管理工具:dbeaver-ce-23.1.5-stable.x86-64.rpm
- 以下是一些适用于英语六级作文的万能句型模板,涵盖了引言、正文和结论部分的各类表达方式.docx
- MATLAB中的非线性规划
- 进行C语言面试资格确认是招聘过程中一个重要的步骤,目的是确保候选人具备足够的C语言编程能力和知识.docx
- Java 轻量级的集群负载均衡设计
- 纹身师个人网站模板.jpg
- 在C语言中,连接两个字符串(即将一个字符串附加到另一个字符串的末尾)通常可以使用标准库中的 `strcat` 函数.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈