@echo off REM Check if the script is running with administrative privileges net session >nul 2>&1 if %errorLevel% neq 0 ( echo Administrative privileges required. Re-running script with elevated permissions... powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList '%*'" exit /b ) REM Now we are running with administrative privileges pushd "%~dp0" dir /b %SystemRoot%servicingPackages*Hyper-V*.mum >hyper-v.txt for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do ( dism /online /norestart /add-package:"%SystemRoot%servicingPackages%%i" ) del hyper-v.txt REM Check if the Hyper-V feature is installed before attempting to enable it dism /online /get-features | find "Microsoft-Hyper-V" >nul if %errorlevel% equ 0 ( Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL ) else ( echo Hyper-V feature not found or already enabled. ) pause