说明
跟虚拟化相关的三个程序
一键开启脚本
@REM 开启 Hyper-V 服务
pushd "%~dp0"dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txtfor /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"del hyper-v.txt@REM 启用Hyper-V
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL /norestart
@REM 禁用 Hyper-V
@REM DISM /Online /Disable-Feature:Microsoft-Hyper-V-All /norestart@REM 安装 WSL 2 之前,必须启用“虚拟机平台”可选功能。
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
@REM 安装wsl
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart
@REM 删除wsl
@REM dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart
一键关闭脚本
@REM 关闭物理机虚拟化,是的虚拟机可以正常虚拟化@REM 安装 WSL 2 之前,必须启用“虚拟机平台”可选功能。
dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /norestart@REM 禁用 Hyper-V
DISM /Online /Disable-Feature:Microsoft-Hyper-V-All /norestart@REM 删除wsl
dism.exe /online /disable-feature /featurename:Microsoft-Windows-Subsystem-Linux /norestart