A cross-platform command launcher for administrator privileges.
Project description
py-admin-launch
A cross-platform Python command/helper to launch a specified program with administrator privileges.
Strategy
- Linux desktop:
pkexecfor polkit GUI authentication, falling back tosudowhenpkexecis not available. - Windows:
ShellExecuteW(..., "runas", ...). - macOS:
osascript+with administrator privileges, falling back tosudowhenosascriptis not available.
If the current process is already administrator/root, the command is launched directly as the current user.
CLI
Run from source:
python -m py_admin_launch -- your-command arg1 arg2
After installing the package:
py-admin-launch -- your-command arg1 arg2
Useful options:
py-admin-launch --wait --cwd /path/to/workdir -- your-command arg1 arg2
Python API
from py_admin_launch import launch
launch(["python", "-m", "http.server", "80"])
launch() accepts a command list plus optional cwd and wait arguments:
result = launch(["your-command", "arg1"], cwd="/tmp", wait=True)
print(result.elevated, result.returncode)
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
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 py_admin_launch-0.1.0.tar.gz.
File metadata
- Download URL: py_admin_launch-0.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a0ddd0c082e030680b2c8a7df230ed27a1386307c89ee7c0c9fd96fa61c570e
|
|
| MD5 |
bc6d4f8998b0f1fd0eb51de4a974708b
|
|
| BLAKE2b-256 |
0a7463fc0ccd1995565616177b2525fb3320606c2035a5f6ff6cab44d30567fe
|
File details
Details for the file py_admin_launch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_admin_launch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
affd61c715b746bca2000df6aa25992e126cef4853a7c49a57c2958fe66207ea
|
|
| MD5 |
4833cbc8c10833ee9664693276fabc33
|
|
| BLAKE2b-256 |
604f21894d1ae3850675c03ad5f83537722124d29211aa63c2e2998a23cd3f62
|