py-win-mp-exclude
py-win-mp-exclude is a Windows package for adding, removing, and listing
Microsoft Defender path exclusions from a CLI, a small GUI, or Python code.
The tool uses PowerShell's Defender cmdlets:
Add-MpPreference -ExclusionPathRemove-MpPreference -ExclusionPathGet-MpPreference
When a CLI subcommand or the GUI starts without administrator privileges, the
program relaunches itself once through
py-admin-launch. A hidden startup
flag prevents repeated elevation attempts. --dry-run commands only print the
PowerShell script and do not request elevation.
Installation
pip install py-win-mp-exclude
CLI
Add a file or folder exclusion:
win-mp-exclude add C:\path\to\file.exe
win-mp-exclude add C:\path\to\folder
Remove a file or folder exclusion:
win-mp-exclude remove C:\path\to\file.exe
win-mp-exclude remove C:\path\to\folder
List configured path exclusions:
win-mp-exclude list
Preview the PowerShell command without running it:
win-mp-exclude --dry-run add C:\path\to\folder
The package also installs the alias py-win-mp-exclude.
GUI
Launch the graphical interface:
win-mp-exclude-gui
The GUI can add exclusions, remove exclusions, remove a selected exclusion, list
current exclusions, and refresh the list. The package also installs the alias
py-win-mp-exclude-gui.
Python API
The Python API exposes the same add, remove, list, and dry-run capabilities used by the CLI and GUI:
from win_mp_exclude import add_exclusion, list_exclusions, remove_exclusion
add_result = add_exclusion(r"C:\path\to\folder")
print(add_result.message)
for path in list_exclusions().exclusions:
print(path)
remove_result = remove_exclusion(r"C:\path\to\folder")
print(remove_result.message)
Use dry_run=True to inspect the PowerShell script without applying a change:
from win_mp_exclude import add_exclusion
result = add_exclusion(r"C:\path\to\folder", dry_run=True)
print(result.script)
By default, Python mutating calls can request administrator elevation once. Pass
elevate=False if your program wants to handle elevation itself.
Development
Build with Poetry:
poetry build
Publish with Poetry:
poetry publish
Metadata
Release files for py-win-mp-exclude 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_win_mp_exclude-0.2.2.tar.gz | 7.2 kB | Without provenance | Details for py_win_mp_exclude-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_win_mp_exclude-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for py_win_mp_exclude-0.2.2-py3-none-any.whl |
Total release size: 17.3 kB
Release files / py_win_mp_exclude-0.2.2.tar.gz
| Download URL | py_win_mp_exclude-0.2.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12982b0c03a78d4fc2829ad7b1facb6f5ac670492bc04f911d40b9f874900cbb
|
|
BLAKE2b-256 checksum How to use checksums |
e4892cc7d4c0d11d1156ba87db9c947ee438ca15a6a2163a730cac6906bb3ad9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Release files / py_win_mp_exclude-0.2.2-py3-none-any.whl
| Download URL | py_win_mp_exclude-0.2.2-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5fed7a0b631394e4f02ace4c2f0ff84f55fc06914da6c6f91c34e2b4c9a954d
|
|
BLAKE2b-256 checksum How to use checksums |
68d5d79eb8cb5ef317b020517fc4e6f133f38e49f81ddd92c082414816e89088
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Security for py-win-mp-exclude 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.