py-win-ban-hyperv
Disable or restore Hyper-V virtualization on Windows systems.
This package is useful when software such as some Android emulators, nested virtualization tools, or low-level debugging utilities needs the Windows hypervisor to be completely disabled. It can also restore the same Windows features when you want to use Hyper-V, WSL 2, Windows Sandbox, Virtual Machine Platform, Device Guard, or Credential Guard again.
This tool changes boot configuration, optional Windows features, and system registry values. Run it only from an administrator account and reboot after each operation.
Installation
pip install py-win-ban-hyperv
CLI Usage
Disable Hyper-V and related virtualization security features:
# you need to reboot after running this script
python -m py_win_ban_hyperv
# schedule a reboot for you after done (in 30s)
python -m py_win_ban_hyperv --reboot
# skip the confirmation prompt for non-interactive use
python -m py_win_ban_hyperv --yes
Restore Hyper-V and related virtualization security features:
# you need to reboot after running this script
python -m py_win_ban_hyperv --restore
# schedule a reboot for you after done (in 30s)
python -m py_win_ban_hyperv --restore --reboot
# restore non-interactively and schedule a reboot
python -m py_win_ban_hyperv --restore --reboot --yes
Python API
from py_win_ban_hyperv import ban_hyper_v, restore_hyper_v
ban_hyper_v(reboot=False) # or reboot=True
restore_hyper_v(reboot=False) # or reboot=True
Both functions request administrator privileges through py-admin-launch and
then execute the bundled PowerShell scripts.
How It Works
The Python entry point is intentionally small. It asks for confirmation unless
--yes is passed, parses --restore and --reboot, then launches one
PowerShell script with elevated permissions:
ban_hyperv.ps1disables the Windows hypervisor boot entry, VBS, HVCI, Credential Guard, Hyper-V, Virtual Machine Platform, Windows Hypervisor Platform, and Windows Sandbox.restore_hyperv.ps1enables the matching boot, registry, and optional Windows feature settings again.dgreadiness_v3.6/DG_Readiness_Tool_v3.6.ps1is Microsoft's Device Guard and Credential Guard readiness tool. The disable flow runs it with-Disable; the restore flow runs it with-Enable.
The disable flow mainly performs these operations:
bcdedit /set "{current}" hypervisorlaunchtype off- sets Device Guard, HVCI, and LSA registry values to disabled states
- disables Windows optional features with
dism /online /disable-feature - runs the DG/CG readiness tool with
-Disable
The restore flow performs the corresponding reverse operations:
bcdedit /set "{current}" hypervisorlaunchtype auto- sets Device Guard, HVCI, and LSA registry values to enabled states
- enables Windows optional features with
dism /online /enable-feature /all - runs the DG/CG readiness tool with
-Enable
Project Components
py_win_ban_hyperv/__main__.pyprovides the CLI.py_win_ban_hyperv/core.pyexposes the Python API and elevated launcher.py_win_ban_hyperv/ban_hyperv.ps1contains the disable workflow.py_win_ban_hyperv/restore_hyperv.ps1contains the restore workflow.py_win_ban_hyperv/dgreadiness_v3.6/contains the bundled DG/CG readiness tool and its policy files.
Notes
- A reboot is required before Windows fully applies either operation.
--rebootschedules a restart 30 seconds after the PowerShell script completes.- Restoring Hyper-V may re-enable security features that affect other virtualization software. Disabling Hyper-V may affect WSL 2, Windows Sandbox, Docker Desktop with WSL 2, and other Hyper-V based tools.
Metadata
Release files for py-win-ban-hyperv 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_win_ban_hyperv-0.2.1.tar.gz | 33.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_win_ban_hyperv-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 72.6 kB
Release files / py_win_ban_hyperv-0.2.1.tar.gz
| Download URL | py_win_ban_hyperv-0.2.1.tar.gz |
|---|---|
| Size | 33.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91164155cdb5b0931f2a28b6d55dedd9f5315a8e7d27f246139e5499b24a8bec
|
|
BLAKE2b-256 checksum How to use checksums |
ae9da1c905d78262bc880b3625453bf602044cefd43ab6bc4f37773e32b8e820
|
| 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_ban_hyperv-0.2.1-py3-none-any.whl
| Download URL | py_win_ban_hyperv-0.2.1-py3-none-any.whl |
|---|---|
| Size | 39.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f313922e4125b7b2351b02cdda374a447445086013ea0fd291c37cbc0e87c063
|
|
BLAKE2b-256 checksum How to use checksums |
30fa710ad68eb20bae3257194b3101d5d03d00b9c30184616157c7d6a12b0e12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|