-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bat
More file actions
193 lines (162 loc) · 6.33 KB
/
setup.bat
File metadata and controls
193 lines (162 loc) · 6.33 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
188
189
190
191
192
193
@echo off
setlocal enabledelayedexpansion
REM Check if running as administrator
echo Checking administrator privileges...
net session >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo.
echo ========================================
echo ERROR: Administrator privileges required
echo ========================================
echo.
echo This script must be run as Administrator to install PowerShell 7
echo and set up the development environment properly.
echo.
echo Please:
echo 1. Right-click on this batch file
echo 2. Select "Run as administrator"
echo 3. Click "Yes" when prompted by User Account Control
echo.
pause
exit /b 1
)
echo Administrator privileges confirmed.
echo.
echo ====================================================================
echo LBA2 Community - IdaJS - Easy Build Script
echo ====================================================================
echo.
REM Check if we're running on Windows 10 or 11
echo Checking Windows Kernel NT version...
REM Simple check: look for "Version 10." in ver command output
REM Both Windows 10 and Windows 11 use NT kernel version 10
ver | findstr /C:"Version 10." >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo Windows version check passed: Windows 10 or 11 detected
) else (
echo ERROR: This script requires Windows 10 or Windows 11.
echo Your current version:
ver
echo Please upgrade your Windows and try again.
pause
exit /b 1
)
echo.
REM Check if PowerShell 7 is installed
echo Checking for PowerShell 7...
pwsh.exe -Command "Write-Host 'PowerShell 7 detected'" >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo PowerShell 7 is already installed.
goto :run_setup
)
echo PowerShell 7 not found. Downloading and installing...
echo.
REM Create temp directory for download
set TEMP_DIR=%TEMP%\PS7Setup
if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%"
REM Detect architecture
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
set ARCH=x64
) else if "%PROCESSOR_ARCHITECTURE%"=="ARM64" (
set ARCH=arm64
) else (
set ARCH=x86
)
echo Detected architecture: %ARCH%
REM Download PowerShell 7 MSI
set PS7_URL=https://github.com/PowerShell/PowerShell/releases/download/v7.5.2/PowerShell-7.5.2-win-%ARCH%.msi
set PS7_MSI=%TEMP_DIR%\PowerShell-7.5.2-win-%ARCH%.msi
echo Downloading PowerShell 7 from: %PS7_URL%
powershell.exe -Command "& {[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $ProgressPreference = 'SilentlyContinue'; $webClient = New-Object System.Net.WebClient; $webClient.DownloadFile('%PS7_URL%', '%PS7_MSI%'); $webClient.Dispose()}"
if not exist "%PS7_MSI%" (
echo ERROR: Failed to download PowerShell 7 installer.
echo Please check your internet connection and try again.
pause
exit /b 1
)
echo Download completed successfully.
echo Installing PowerShell 7...
REM Install PowerShell 7 silently and wait for completion
msiexec /i "%PS7_MSI%" /quiet /norestart /l*v "%TEMP%\PS7Install.log"
set INSTALL_EXIT_CODE=%ERRORLEVEL%
if %INSTALL_EXIT_CODE% NEQ 0 (
echo ERROR: PowerShell 7 installation failed with exit code %INSTALL_EXIT_CODE%
echo Installation log available at: %TEMP%\PS7Install.log
echo.
echo Common solutions:
echo - Run this script as Administrator
echo - Check if Windows Installer service is running
echo - Ensure no other installations are in progress
pause
exit /b %INSTALL_EXIT_CODE%
)
REM Wait longer for installation to fully complete and PATH to be updated
echo Waiting for installation to complete and PATH to be updated...
timeout /t 30 /nobreak >nul
REM Try to refresh environment variables
call :RefreshEnv
REM Clean up
if exist "%PS7_MSI%" del "%PS7_MSI%"
if exist "%TEMP_DIR%" rmdir "%TEMP_DIR%"
REM Verify installation with multiple attempts
echo Verifying PowerShell 7 installation...
set VERIFICATION_ATTEMPTS=0
:VerifyLoop
set /a VERIFICATION_ATTEMPTS+=1
if %VERIFICATION_ATTEMPTS% GTR 15 goto :VerifyFailed
REM Try direct path first
if exist "%ProgramFiles%\PowerShell\7\pwsh.exe" (
"%ProgramFiles%\PowerShell\7\pwsh.exe" -Command "Write-Host 'PowerShell 7 installation verified'" >nul 2>&1
if !ERRORLEVEL! EQU 0 goto :VerifySuccess
)
REM Try PATH-based execution
pwsh.exe -Command "Write-Host 'PowerShell 7 installation verified'" >nul 2>&1
if %ERRORLEVEL% EQU 0 goto :VerifySuccess
echo Attempt %VERIFICATION_ATTEMPTS%: PowerShell 7 not ready yet, waiting...
timeout /t 5 /nobreak >nul
goto :VerifyLoop
:VerifyFailed
echo ERROR: PowerShell 7 installation failed or PowerShell 7 is not accessible.
echo Installation log available at: %TEMP%\PS7Install.log
echo.
echo Please try the following:
echo 1. Restart your command prompt as Administrator and run this script again
echo 2. Manually add %ProgramFiles%\PowerShell\7\ to your PATH
echo 3. Check the installation log for detailed error information
pause
exit /b 1
:VerifySuccess
echo PowerShell 7 installed and verified successfully!
echo.
:run_setup
echo Running complete build process using PowerShell 7...
echo.
REM Run compile.ps1 with PowerShell 7 - use full path to avoid PATH issues
REM First try the full path, then fall back to PATH-based execution
if exist "C:\Program Files\PowerShell\7\pwsh.exe" (
"C:\Program Files\PowerShell\7\pwsh.exe" -ExecutionPolicy Bypass -Command "Set-Location '%~dp0'; & '%~dp0compile.ps1'"
) else (
pwsh.exe -ExecutionPolicy Bypass -Command "Set-Location '%~dp0'; & '%~dp0compile.ps1'"
)
if %ERRORLEVEL% NEQ 0 (
echo.
echo ERROR: compile.ps1 execution failed with exit code %ERRORLEVEL%
echo.
echo The complete build process failed. Please check the error messages above.
echo To run the complete process again run: .\compile.ps1 from PowerShell 7.
pause
exit /b %ERRORLEVEL%
)
echo.
pause
:RefreshEnv
REM Refresh environment variables without requiring a restart
for /f %%i in ('echo %PATH%') do set CURRENT_PATH=%%i
for /f "skip=2 tokens=3*" %%a in ('reg query HKLM\SYSTEM\CurrentControlSet\Control\Session" "Manager\Environment /v PATH') do set SYSTEM_PATH=%%b
for /f "skip=2 tokens=3*" %%a in ('reg query HKCU\Environment /v PATH 2^>nul') do set USER_PATH=%%b
if defined USER_PATH (
set "PATH=%SYSTEM_PATH%;%USER_PATH%"
) else (
set "PATH=%SYSTEM_PATH%"
)
goto :eof