Skip to content

Instantly share code, notes, and snippets.

@YenHub
Last active February 12, 2020 19:35
Show Gist options
  • Save YenHub/6985aea04d0f7f1e886af77b830f8fcf to your computer and use it in GitHub Desktop.
Save YenHub/6985aea04d0f7f1e886af77b830f8fcf to your computer and use it in GitHub Desktop.
Toggle Hyper-V

Toggle Windows Hyper-V Batch Script

Fun Facts

Virtualisation software (e.g. Virtual Box, VMware, Windows Sandbox), DOCKER!!, and many other wares require the presence of this feature in order to function normally.

But wait... why would you ever even want to disable Hyper-V in the first place??

Reasons

This script was written in order to tackle the mundane process of toggling Hyper-V for these purposes.

Usage

WARNING!! Upon toggling, your system will reboot - so be sure to save any work before toggling!

Simply download this gist and run hyper-v.bat it as administrator.

Optionally, save it somewhere and add a shortcut to your desktop, customising the icon appropriately and setting it to automagically run as adminstrator.

Better yet, turn it into a CLI program and customise the script, passing in the switches required on the command line :)

Enjoy 🚀

Disclaimer:

I am not a doctor, lawyer or anyone that cares remotely if your system starts leaking binary all over the internet or your coffee table.

No warranties are implied; please use my tools at your own discretion, study them, share them and enjoy them as you see fit!

@Echo off
setlocal EnableDelayedExpansion
set 1=auto
set 2=off
set 3=exit
Echo/
echo " __ __ __ __ ";
echo " / | / | / | / | ";
echo " $$ | $$ | __ __ ______ ______ ______ $$ | $$ | ";
echo " $$ |__$$ |/ | / | / \ / \ / \ ______ $$ | $$ | ";
echo " $$ $$ |$$ | $$ |/$$$$$$ |/$$$$$$ |/$$$$$$ |/ |$$ \ /$$/ ";
echo " $$$$$$$$ |$$ | $$ |$$ | $$ |$$ $$ |$$ | $$/ $$$$$$/ $$ /$$/ ";
echo " $$ | $$ |$$ \__$$ |$$ |__$$ |$$$$$$$$/ $$ | $$ $$/ ";
echo " $$ | $$ |$$ $$ |$$ $$/ $$ |$$ | $$$/ ";
echo " $$/ $$/ $$$$$$$ |$$$$$$$/ $$$$$$$/ $$/ $/ ";
echo " / \__$$ |$$ | ";
echo " $$ $$/ $$ | ";
echo " $$$$$$/ $$/ ";
echo " __ __ ";
echo " / \ / | ";
echo " $$ \ /$$ | ______ _______ ______ ______ ______ ______ ";
echo " $$$ \ /$$$ | / \ / \ / \ / \ / \ / \ ";
echo " $$$$ /$$$$ | $$$$$$ |$$$$$$$ | $$$$$$ |/$$$$$$ |/$$$$$$ |/$$$$$$ | ";
echo " $$ $$ $$/$$ | / $$ |$$ | $$ | / $$ |$$ | $$ |$$ $$ |$$ | $$/ ";
echo " $$ |$$$/ $$ |/$$$$$$$ |$$ | $$ |/$$$$$$$ |$$ \__$$ |$$$$$$$$/ $$ | ";
echo " $$ | $/ $$ |$$ $$ |$$ | $$ |$$ $$ |$$ $$ |$$ |$$ | ";
echo " $$/ $$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$$$$$$ | $$$$$$$/ $$/ ";
echo " / \__$$ | ";
echo " $$ $$/ ";
echo " $$$$$$/ ";
Echo Toggle Windows Hyper-V
Echo/
Echo. ---------------------------[*]
Echo. [ 1 ] = Turn On Hyper-V
Echo. ---------------------------[*]
Echo. [ 2 ] = Turn Off Hyper-V
Echo. ---------------------------[*]
Echo. [ 3 ] = CANCEL
Echo. ---------------------------[*]
Echo/
set /p Opt=Choose Your Weapon:
set HVStatus=!%Opt%!
if "%opt%" == "3" (exit) else (BCDEDIT /Set {current} hypervisorlaunchtype %HVStatus% && shutdown -r -t 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment