Facebook
From me, 1 Month ago, written in Bash.
Embed
Download Paste or View Raw
Hits: 33
  1. @echo off
  2. REM Check if the script is running with administrative privileges
  3. net session >nul 2>&1
  4. if %errorLevel% neq 0 (
  5.     echo Administrative privileges required. Re-running script with elevated permissions...
  6.     powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList '%*'"
  7.     exit /b
  8. )
  9.  
  10. REM Now we are running with administrative privileges
  11.  
  12. pushd "%~dp0"
  13.  
  14. dir /b %SystemRoot%servicingPackages*Hyper-V*.mum >hyper-v.txt
  15.  
  16. for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do (
  17.     dism /online /norestart /add-package:"%SystemRoot%servicingPackages%%i"
  18. )
  19.  
  20. del hyper-v.txt
  21.  
  22. REM Check if the Hyper-V feature is installed before attempting to enable it
  23. dism /online /get-features | find "Microsoft-Hyper-V" >nul
  24. if %errorlevel% equ 0 (
  25.     Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
  26. ) else (
  27.     echo Hyper-V feature not found or already enabled.
  28. )
  29.  
  30. pause

Replies to code rss

Title Name Language When
Re: code meew bash 1 Month ago.
captcha