Advertisement
Combreal

InstallWSL.bat

Apr 22nd, 2020
1,274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.36 KB | None | 0 0
  1. REM here is how to download a new version of the archive in powershell to C:\Temp, just change 1804 with the desired version :
  2. REM powershell -command "Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile C:\Temp\ubuntu.zip -UseBasicParsing"
  3. REM then upload the new version of the archive to the file set WSL-Ubuntu
  4.  
  5. @echo off
  6. set WSLExec=ubuntu1804.exe REM version change here
  7.  
  8. if not exist "C:\Windows\System32\bash.exe" (
  9.   dism /online /Enable-Feature /featurename:Microsoft-Windows-Subsystem-Linux /All
  10.   shutdown /r /t 0
  11. )
  12.  
  13. for /f "tokens=3 delims= " %%a in ('reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage') do (
  14.   if [%%a] EQU [0409] (for /f "tokens=3" %%a in ('net config workstation^|find "User name"') do set theUserName=%%a)
  15.   if [%%a] EQU [040C] (for /f "tokens=3" %%a in ('net config workstation^|find "Nom d'utilisateur"') do set theUserName=%%a)
  16. )
  17.  
  18. if not exist "c:\Users\%theUserName%\UbuntuWSL\" mkdir c:\Users\%theUserName%\UbuntuWSL
  19. cd c:\Users\%theUserName%\UbuntuWSL
  20. copy %~dp0NAT_APP_InstallWSL.sh
  21. tar -xf "%~dp0ubuntu.zip"
  22.  
  23. %WSLExec% install --root
  24. %WSLExec% run /mnt/c/Users/%theUserName%/UbuntuWSL/NAT_APP_InstallWSL.sh %theUserName%
  25. %WSLExec% config --default-user %theUserName%
  26.  
  27. bash -c ls >nul: 2>nul:
  28. if %ERRORLEVEL% NEQ 0 (
  29.   wslconfig /u Ubuntu-18.04 REM version change here
  30. )
  31.  
  32. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement