-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathwsl-install.bat
More file actions
187 lines (169 loc) · 5.47 KB
/
wsl-install.bat
File metadata and controls
187 lines (169 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
@echo off
setlocal EnableDelayedExpansion
cls
echo ======================================================================
echo Waldo Alpha - WSL Installation Script
echo ======================================================================
echo.
echo This script will install Windows Subsystem for Linux (WSL) with Ubuntu
echo and prepare your system to run the Waldo Alpha application.
echo.
echo NOTE: This process requires administrator privileges and will need
echo a system restart after WSL installation.
echo.
echo ======================================================================
echo.
pause
REM Check for administrator privileges
net session >nul 2>&1
if %errorlevel% neq 0 (
echo.
echo ERROR: This script requires administrator privileges.
echo.
echo Please right-click on this file and select "Run as administrator"
echo or use one of these methods:
echo 1. Right-click Start Menu, select "Windows Terminal (Admin)"
echo 2. Type: cd "%~dp0"
echo 3. Type: wsl-install.bat
echo.
pause
exit /b 1
)
echo.
echo STEP 1: Checking Windows version...
echo ----------------------------------------------------------------------
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
echo Windows version detected: %VERSION%
REM Check if Windows version supports WSL
if "%VERSION%" LSS "10.0" (
echo ERROR: WSL requires Windows 10 or later.
echo Your version: %VERSION%
pause
exit /b 1
)
echo Windows version is compatible with WSL.
echo.
echo STEP 2: Checking WSL and Ubuntu installation status...
echo ----------------------------------------------------------------------
REM Check if any distributions are installed
wsl --list --quiet >nul 2>&1
if %errorlevel% neq 0 (
echo WSL is not installed or no distributions found.
echo Proceeding with full WSL installation...
goto :INSTALL_WSL
)
REM If we get here, WSL has distributions - check for Ubuntu specifically
echo WSL is installed. Checking for Ubuntu...
wsl --list --quiet | findstr /i "Ubuntu" >nul 2>&1
if %errorlevel% equ 0 (
echo Ubuntu is already installed.
echo.
echo Testing Ubuntu connection...
wsl -d Ubuntu echo "Test successful" >nul 2>&1
if %errorlevel% equ 0 (
echo Ubuntu is working properly.
echo You can proceed directly to wsl-setup.bat
echo.
pause
exit /b 0
) else (
echo Ubuntu is installed but not working properly.
echo Reinstalling Ubuntu...
goto :INSTALL_UBUNTU
)
) else (
echo Ubuntu is not installed. Installing Ubuntu...
goto :INSTALL_UBUNTU
)
:INSTALL_WSL
echo.
echo STEP 3: Enabling required Windows features...
echo ----------------------------------------------------------------------
echo This may take several minutes...
echo.
REM Enable Windows Subsystem for Linux
echo Enabling Windows Subsystem for Linux...
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
if %errorlevel% neq 0 (
echo ERROR: Failed to enable WSL feature.
pause
exit /b 1
)
REM Enable Virtual Machine Platform for WSL 2
echo.
echo Enabling Virtual Machine Platform...
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
if %errorlevel% neq 0 (
echo WARNING: Could not enable Virtual Machine Platform.
echo WSL 1 will be used instead of WSL 2.
)
echo.
echo STEP 4: Installing WSL and Ubuntu...
echo ----------------------------------------------------------------------
echo This will download and install Ubuntu. This may take 10-20 minutes...
echo.
REM Install WSL with Ubuntu
wsl --install -d Ubuntu
if %errorlevel% neq 0 (
echo.
echo WARNING: WSL installation may have encountered issues.
echo Attempting alternative installation method...
echo.
REM Try installing just WSL first
wsl --install --no-distribution
REM Then install Ubuntu separately
:INSTALL_UBUNTU
echo.
echo Installing Ubuntu distribution...
wsl --install -d Ubuntu
if %errorlevel% neq 0 (
echo.
echo ERROR: Failed to install Ubuntu.
echo.
echo Please try the following:
echo 1. Restart your computer
echo 2. Run this script again
echo 3. If it still fails, install Ubuntu manually from Microsoft Store
echo.
pause
exit /b 1
)
)
echo.
echo STEP 5: Setting WSL 2 as default version...
echo ----------------------------------------------------------------------
wsl --set-default-version 2 >nul 2>&1
if %errorlevel% equ 0 (
echo WSL 2 set as default version.
) else (
echo WSL 1 will be used (WSL 2 not available on this system).
)
echo.
echo ======================================================================
echo INSTALLATION COMPLETE - RESTART REQUIRED
echo ======================================================================
echo.
echo WSL and Ubuntu have been installed successfully!
echo.
echo IMPORTANT: You must restart your computer before proceeding.
echo.
echo After restarting:
echo 1. Ubuntu will prompt you to create a username and password
echo 2. Remember these credentials - you'll need them
echo 3. Run wsl-setup.bat to install the Waldo Alpha application
echo.
echo Would you like to restart now? (Y/N)
choice /c YN /m "Restart computer"
if errorlevel 2 (
echo.
echo Please restart manually before running wsl-setup.bat
echo.
pause
exit /b 0
) else (
echo.
echo Restarting in 10 seconds...
echo Save any open work now!
timeout /t 10
shutdown /r /t 0
)