Queses

Win10 Home Enable HyperV

Mar 28th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.11 KB | None | 0 0
  1. @echo off
  2.  
  3. echo Checking for permissions
  4. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  5.  
  6. echo Permission check result: %errorlevel%
  7.  
  8. REM --> If error flag set, we do not have admin.
  9. if '%errorlevel%' NEQ '0' (
  10. echo Requesting administrative privileges...
  11. goto UACPrompt
  12. ) else ( goto gotAdmin )
  13.  
  14. :UACPrompt
  15. echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  16. echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
  17.  
  18. echo Running created temporary "%temp%\getadmin.vbs"
  19. timeout /T 2
  20. "%temp%\getadmin.vbs"
  21. exit /B
  22.  
  23. :gotAdmin
  24. if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
  25. pushd "%CD%"
  26. CD /D "%~dp0"
  27.  
  28. echo Batch was successfully started with admin privileges
  29. echo .
  30. cls
  31. Title Hyper-V Installer
  32.  
  33. pushd "%~dp0"
  34.  
  35. dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
  36.  
  37. for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
  38.  
  39. del hyper-v.txt
  40.  
  41. Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
  42.  
  43. pause
Add Comment
Please, Sign In to add comment