Skip to main content

osn-windows-cmd is 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

osn-windows-cmd: Simplify Windows Command-Line Interactions

osn-windows-cmd 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.

Installation

  • With pip:

    pip install osn-windows-cmd
    
  • With git:

    pip install git+https://github.com/oddshellnick/osn-windows-cmd.git
    

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.

Usage Examples

taskkill:

from osn_windows_cmd.taskkill.parameters import ImageName
from osn_windows_cmd.taskkill import taskkill_windows
# Forcefully kill all notepad.exe processes
taskkill_windows("/F", selectors=ImageName("notepad.exe"))

netstat:

from osn_windows_cmd.netstat import get_netstat_connections_data
# Get all active TCP connections
connections = get_netstat_connections_data(protocol="TCP")

shutdown:

from osn_windows_cmd.shutdown.parameters import ShutdownReason, ShutdownReasonType, ShutdownType
from osn_windows_cmd.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

osn-windows-cmd 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

osn_windows_cmd-1.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osn_windows_cmd-1.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file osn_windows_cmd-1.1.0.tar.gz.

File metadata

  • Download URL: osn_windows_cmd-1.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for osn_windows_cmd-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b4737a7d0b099a39103999302c3ec6bee87ea52b17ca4f3a8bc73c57b5a6b3c8
MD5 8f04008964e6807d62667636ecd6ac65
BLAKE2b-256 38382f9efea57c66eccaa0906d8dcac6c038d9b6bc7a7f63f74448d3bcb7db5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for osn_windows_cmd-1.1.0.tar.gz:

Publisher: python-publish.yml on oddshellnick/osn-windows-cmd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file osn_windows_cmd-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for osn_windows_cmd-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8406b638700797b9b5c3541e14b2c128032fe7fbadcc429370f96f633b82b4cd
MD5 e4e589d2bae850f1bd322cb1fc122d59
BLAKE2b-256 db06dd054a930d794bac731e31123fc2c6f7bc00a1a0589cae6d0714cc1cee24

See more details on using hashes here.

Provenance

The following attestation bundles were made for osn_windows_cmd-1.1.0-py3-none-any.whl:

Publisher: python-publish.yml on oddshellnick/osn-windows-cmd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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