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.0.0.tar.gz (13.8 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.0.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: osn_windows_cmd-1.0.0.tar.gz
  • Upload date:
  • Size: 13.8 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.0.0.tar.gz
Algorithm Hash digest
SHA256 b864c204c3c4b7c8fe907d65e10753d9c7b295cb964147e28216e8f76a7a26c4
MD5 3a09666a77d944d7da9af87b2a7f12df
BLAKE2b-256 df5a0460c037bad797d7c44a18f8495ca1ee3df6b2f959f8b922cd6dd09b5114

See more details on using hashes here.

Provenance

The following attestation bundles were made for osn_windows_cmd-1.0.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.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for osn_windows_cmd-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 234dc1557f0c011744a5e37480a31a7eed4d23d72c177dc2f4de2e6b074232a6
MD5 892abce325e2ec1ee0dee1fc00883a5f
BLAKE2b-256 ef103668406e0175e2d9b9e2c32830ba1a9197d5b2db29a643fd3d5f0da9b293

See more details on using hashes here.

Provenance

The following attestation bundles were made for osn_windows_cmd-1.0.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