Metadata-Version: 2.4
Name: py-win-mp-exclude
Version: 0.2.1
Summary: Manage Microsoft Defender path exclusions from Python, CLI, or GUI.
License-Expression: MIT
License-File: LICENSE
Keywords: windows,defender,microsoft-defender,exclusions,powershell
Author: GGN_2015
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Dist: py-admin-launch (>=0.1.3,<0.2.0)
Project-URL: Repository, https://github.com/GGN-2015/py-win-mp-exclude
Description-Content-Type: text/markdown

# 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 -ExclusionPath`
- `Remove-MpPreference -ExclusionPath`
- `Get-MpPreference`

When a CLI subcommand or the GUI starts without administrator privileges, the
program relaunches itself once through
[`py-admin-launch`](https://pypi.org/project/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

```powershell
pip install py-win-mp-exclude
```

## CLI

Add a file or folder exclusion:

```powershell
win-mp-exclude add C:\path\to\file.exe
win-mp-exclude add C:\path\to\folder
```

Remove a file or folder exclusion:

```powershell
win-mp-exclude remove C:\path\to\file.exe
win-mp-exclude remove C:\path\to\folder
```

List configured path exclusions:

```powershell
win-mp-exclude list
```

Preview the PowerShell command without running it:

```powershell
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:

```powershell
win-mp-exclude-gui
```

The GUI can add exclusions, remove exclusions, remove a selected exclusion, list
current exclusions, and preview the PowerShell command it will run. 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:

```python
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:

```python
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:

```powershell
poetry build
```

Publish with Poetry:

```powershell
poetry publish
```

