Skip to main content

A Python library to simplify working with Windows command-line utilities like `netstat`, `shutdown`, and `taskkill`, providing structured output and a convenient interface.

Project description

PyWindowsCMD is a Python library designed to streamline working with common Windows command-line tools. It provides convenient functions and parameter handling for commands like netstat, shutdown, and taskkill, abstracting away the complexities of constructing and executing these commands directly.

Key Features

  • Simplified Command Execution: Construct and execute Windows commands with intuitive function calls and parameter management.

  • Structured Output Parsing: Process the output of commands like netstat into easy-to-use Pandas DataFrames.

  • Cross-Compatibility: Designed to work seamlessly across various Windows versions.

  • Clear Documentation and Examples: Well-documented code and usage examples to get you started quickly.

Current Functionality

  • netstat: Retrieve system network statistics, including active connections, routing tables, and interface information. Parse the returned data directly into Pandas DataFrames. Conveniently find free ports on localhost.

  • shutdown: Initiate shutdowns and restarts of local or remote Windows systems with various options (forceful shutdown, reason logging, timeout period, etc.).

  • taskkill: Terminate processes based on various criteria such as image name or process ID.

Installation

Install PyWindowsCMD using pip:

pip install PyWindowsCMD

Usage Examples

taskkill:

from PyWindowsCMD.taskkill.parameters import ImageName
from PyWindowsCMD.taskkill import taskkill_windows

# Forcefully kill all notepad.exe processes
taskkill_windows("/F", selectors=ImageName("notepad.exe"))

netstat:

from PyWindowsCMD.netstat import get_netstat_connections_data

# Get all active TCP connections
connections = get_netstat_connections_data(protocol="TCP")

shutdown:

from PyWindowsCMD.shutdown.parameters import ShutdownReason, ShutdownReasonType, ShutdownType
from PyWindowsCMD.shutdown import shutdown_windows

# Restart the local machine after 60 seconds, logging the reason
shutdown_windows(ShutdownType.restart, time_out_period=60, shutdown_reason=ShutdownReason(ShutdownReasonType.planned, 4, 2))

More comprehensive usage examples and detailed documentation can be found within the project’s source code docstrings.

Future Notes

PyWindowsCMD is an ongoing project and will be expanded to support more Windows commands in the future. We welcome contributions from the community. Feel free to suggest new commands to be added or submit pull requests with your own implementations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywindowscmd-1.3.6.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

PyWindowsCMD-1.3.6-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file pywindowscmd-1.3.6.tar.gz.

File metadata

  • Download URL: pywindowscmd-1.3.6.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pywindowscmd-1.3.6.tar.gz
Algorithm Hash digest
SHA256 a9ca67e92698d69a367c9a25e066b8f786cd5c7fa9ef52e94a69a5e38fb760f8
MD5 25f66879bf8c29c1a33e81f11b2e498a
BLAKE2b-256 4fffc06c5d2a2640b7251f83d55c1a91dbe635e35073c14989d6b9c9c02f28d4

See more details on using hashes here.

File details

Details for the file PyWindowsCMD-1.3.6-py3-none-any.whl.

File metadata

  • Download URL: PyWindowsCMD-1.3.6-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for PyWindowsCMD-1.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bbcfe8fe1b229fdb6a6a681348c015e8d64f428312c6cca9b473db01d57ba1ac
MD5 5713909ddbac53e8836a4499bc4a2015
BLAKE2b-256 48197e1c088996353740748b085643b3e2413f1fb2834a5d0c7d14dabc07f506

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page