Last active
March 23, 2023 13:59
-
-
Save bengarrett/9dc8305d42eed33ff32d to your computer and use it in GitHub Desktop.
Changes the status of Windows Hyper-V to enable you to use other Virtualization software such as VirtualBox and VMware.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::File: c:\terminal\cmd-scripts\hyper-v.cmd | |
@echo off | |
echo. | |
if [%1] == [] goto help1 | |
if "%1" == "/?" goto help1 | |
goto check_Permissions | |
:check_Arguments | |
if /i "%1" == "/on" goto enable | |
if /i "%1" == "/off" goto disable | |
goto err2 | |
:enable | |
echo Enable Hyper-V. | |
bcdedit /set hypervisorlaunchtype auto | |
goto reboot_Request | |
:disable | |
echo Disable Hyper-V. | |
bcdedit /set hypervisorlaunchtype off | |
goto reboot_Request | |
:reboot_Request | |
@echo. | |
echo Please reboot your computer to apply these changes. | |
goto end1 | |
:err1 | |
echo No parameter provided. Please use the following syntax. | |
goto help2 | |
:err2 | |
echo %1 is not a valid parameter. Please use the following syntax. | |
goto help2 | |
:help1 | |
echo Sets the hypervisorlaunchtype in the Boot Configuration Data Store. | |
goto help2 | |
:help2 | |
@echo. | |
echo hyper-v /on - To enable Hyper-V | |
echo hyper-v /off - To disable Hyper-V | |
goto end1 | |
:check_Permissions | |
:: http://stackoverflow.com/questions/4051883/batch-script-how-to-check-for-admin-rights | |
net session >nul 2>&1 | |
if %errorLevel% == 0 ( | |
goto check_Arguments | |
) else ( | |
echo Please run this script as an Administrator. | |
echo The Boot Configuration Data Store can not be accessed as the user %USERNAME%. | |
goto end1 | |
) | |
:end1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment