pypsexec
Run commands on a remote Windows host using SMB/RPC
What it is and what it does
pypsexec is a Python library that executes commands on remote Windows hosts using SMB and RPC protocols, mimicking the behavior of the PsExec tool. It works cross-platform—you can run it from Linux, macOS, or Windows—and does not require PsExec binaries to be installed on the local machine. The library handles the full lifecycle: establishing an SMB connection, copying a PAExec binary to the remote ADMIN$ share, creating a Windows service to run the binary, piping commands and capturing output, and cleaning up afterward.
The package supports running processes as specific users (local, domain, or SYSTEM), interactive sessions, custom process priorities, timeouts, stdin input, and processor affinity. By default it encrypts data in transit using SMB encryption, though older Windows versions (7, Server 2008, Server 2008 R2) do not support this and fall back to XOR scrambling. The main runtime dependency is smbprotocol; Kerberos authentication is optional and requires additional system libraries.
Use it for:
- Automate administrative tasks on remote Windows servers from a Python script running on any OS.
- Deploy or execute batch jobs on Windows hosts without installing PsExec or managing separate binaries.
- Run diagnostics or remediation commands on multiple Windows machines as part of a larger orchestration workflow.
- Execute commands under specific user accounts or the SYSTEM account for privilege-level testing or service management.
- Capture stdout and stderr from remote processes for logging or real-time monitoring in a centralized Python application.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Runs commands on remote Windows hosts via SMB/RPC without requiring local binaries or a specific operating system, using Python to replicate PsExec functionality.
Yes, if you need to run commands on remote Windows hosts from Python and can meet the prerequisites (SMB access, admin credentials, appropriate UAC configuration). The low install friction and permissive license make it straightforward to add. However, note that the package has not been updated since 2021; if you require active maintenance or support for the latest Windows or Python versions, verify compatibility first or consider whether an actively maintained alternative exists.
Install
pypsexec on PyPI
pip
pip install pypsexecuv
uv add pypsexecpoetry
poetry add pypsexecInstalling pypsexec
Before you install
Low install friction with a single runtime dependency (smbprotocol). The package is aging—last release was 2021-10-21 and no updates in over three years—but the repository remains active with recent commits and no archived status.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions; you may use and modify the code freely as long as you include the license notice.
Quickstart
pip install pypsexec
from pypsexec.client import Client
client = Client('remote_host', username='user', password='pass')
client.connect()
stdout, stderr, rc = client.run_executable('cmd.exe', arguments='/c whoami')
client.disconnect()
Remote Windows host must have SMB port 445 open, ADMIN$ share enabled with read/write access, and the connecting user must be an administrator or have appropriate token rights (UAC filtering may block non-admin tokens).
Verify before relying
- Whether the package works with modern Windows Server versions beyond those documented in the description.
- Current compatibility with Python 3.10+ given the last release predates those versions.
- Whether smbprotocol's optional Kerberos support is automatically available or requires separate installation.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — smbprotocol |
| Maintenance | aging — 1,758 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 177,505/month — #10,211 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pypsexec-0.3.0-py2.py3-none-any.whl
Keywords: windows, psexec, paexec, remote, python
Tags
More Networking packages
h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
psutilpsutil retrieves real-time information about…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
uvloopuvloop is a drop-in replacement for Python's…
permissive · top 1,000 on PyPI
execnetexecnet lets you spawn and communicate with…
permissive · top 1,000 on PyPI
pyzmqPyZMQ provides Python bindings for ZeroMQ…
permissive · top 1,000 on PyPI
elevateElevate re-launches the current Python process…
permissive · top 15,000 on PyPI
pypsrpExecute commands, scripts, and file operations…
permissive · top 5,000 on PyPI
smbprotocolSMBv2 and SMBv3 client library for Python that…
permissive · top 5,000 on PyPI
pywinrmpywinrm is a Python client for Windows Remote…
permissive · top 5,000 on PyPI
pysmbpysmb implements the SMB/CIFS protocol to let…
permissive · top 5,000 on PyPI
grpciogRPC Python is an HTTP/2-based RPC framework…
permissive · top 100 on PyPI
winkerberosProvides native Kerberos client authentication…
permissive · top 5,000 on PyPI
requests-credsspAdds CredSSP authentication support to the…
permissive · top 15,000 on PyPI
EasyProcessEasyProcess wraps Python's subprocess module to…
permissive · top 5,000 on PyPI
bashProvides a Python wrapper for running bash…
copyleft · top 15,000 on PyPI