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
netstatinto 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4737a7d0b099a39103999302c3ec6bee87ea52b17ca4f3a8bc73c57b5a6b3c8
|
|
| MD5 |
8f04008964e6807d62667636ecd6ac65
|
|
| BLAKE2b-256 |
38382f9efea57c66eccaa0906d8dcac6c038d9b6bc7a7f63f74448d3bcb7db5b
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osn_windows_cmd-1.1.0.tar.gz -
Subject digest:
b4737a7d0b099a39103999302c3ec6bee87ea52b17ca4f3a8bc73c57b5a6b3c8 - Sigstore transparency entry: 243873576
- Sigstore integration time:
-
Permalink:
oddshellnick/osn-windows-cmd@3d30644fbb58c9e78069cbb28d465971689d7a5f -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/oddshellnick
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3d30644fbb58c9e78069cbb28d465971689d7a5f -
Trigger Event:
release
-
Statement type:
File details
Details for the file osn_windows_cmd-1.1.0-py3-none-any.whl.
File metadata
- Download URL: osn_windows_cmd-1.1.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8406b638700797b9b5c3541e14b2c128032fe7fbadcc429370f96f633b82b4cd
|
|
| MD5 |
e4e589d2bae850f1bd322cb1fc122d59
|
|
| BLAKE2b-256 |
db06dd054a930d794bac731e31123fc2c6f7bc00a1a0589cae6d0714cc1cee24
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
osn_windows_cmd-1.1.0-py3-none-any.whl -
Subject digest:
8406b638700797b9b5c3541e14b2c128032fe7fbadcc429370f96f633b82b4cd - Sigstore transparency entry: 243873579
- Sigstore integration time:
-
Permalink:
oddshellnick/osn-windows-cmd@3d30644fbb58c9e78069cbb28d465971689d7a5f -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/oddshellnick
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3d30644fbb58c9e78069cbb28d465971689d7a5f -
Trigger Event:
release
-
Statement type: