Skip to main content

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.ps1 disables the Windows hypervisor boot entry, VBS, HVCI, Credential Guard, Hyper-V, Virtual Machine Platform, Windows Hypervisor Platform, and Windows Sandbox.
  • restore_hyperv.ps1 enables the matching boot, registry, and optional Windows feature settings again.
  • dgreadiness_v3.6/DG_Readiness_Tool_v3.6.ps1 is 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__.py provides the CLI.
  • py_win_ban_hyperv/core.py exposes the Python API and elevated launcher.
  • py_win_ban_hyperv/ban_hyperv.ps1 contains the disable workflow.
  • py_win_ban_hyperv/restore_hyperv.ps1 contains 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.
  • --reboot schedules 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_win_ban_hyperv-0.2.1.tar.gz (33.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_win_ban_hyperv-0.2.1-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file py_win_ban_hyperv-0.2.1.tar.gz.

File metadata

  • Download URL: py_win_ban_hyperv-0.2.1.tar.gz
  • Upload date:
  • Size: 33.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10

File hashes

Hashes for py_win_ban_hyperv-0.2.1.tar.gz
Algorithm Hash digest
SHA256 91164155cdb5b0931f2a28b6d55dedd9f5315a8e7d27f246139e5499b24a8bec
MD5 97351e7c905b1f6a1b18b8cd04a8651f
BLAKE2b-256 ae9da1c905d78262bc880b3625453bf602044cefd43ab6bc4f37773e32b8e820

See more details on using hashes here.

File details

Details for the file py_win_ban_hyperv-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: py_win_ban_hyperv-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10

File hashes

Hashes for py_win_ban_hyperv-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f313922e4125b7b2351b02cdda374a447445086013ea0fd291c37cbc0e87c063
MD5 adaaf53bf15669a506d7d7a62e543fb8
BLAKE2b-256 30fa710ad68eb20bae3257194b3101d5d03d00b9c30184616157c7d6a12b0e12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page