skillfed

pypsexec

Run commands on a remote Windows host using SMB/RPC

pypsexec v0.3.0 177.5K downloads/30d#10,211 on PyPI138
Permissive license MIT AGING released

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 pypsexec

uv

uv add pypsexec

poetry

poetry add pypsexec

Installing 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

Development Status :: 4 - BetaLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

remote command execution windowspsexec pythonsmb rpc command runnerwindows remote administrationcross-platform psexecpython windows service executionremote process management windows
windows-administrationremote-executionsmb-protocol

More Networking packages