Create enable-WSL2.bat

This commit is contained in:
Spirit 👾 2024-08-19 10:23:40 -07:00 committed by GitHub
parent 8c7b996411
commit a3fb187a1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

34
enable-WSL2.bat Normal file
View File

@ -0,0 +1,34 @@
@echo off
:checkAdminPriv
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c cd %cd% && %~s0 %params%", "", "runas", 1 >> "getadmin.vbs"
"getadmin.vbs"
del "getadmin.vbs"
exit /B
:gotAdmin
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
echo downloading wsl_update_x64...
curl.exe -Ls --remote-name --remove-on-error https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
wsl_update_x64.msi
del "wsl_update_x64.msi"
wsl --set-default-version 2
echo a system reboot might be required
echo Press any key to exit . . .
pause>nul