Skip to content

Commit 61f26f4

Browse files
authored
Update SystemTester.bat
Adding ability to download Sysinternals Suite from within the utility.
1 parent 984e329 commit 61f26f4

1 file changed

Lines changed: 5 additions & 41 deletions

File tree

SystemTester.bat

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if errorlevel 1 (
2222
echo.
2323
echo [ERROR] Elevation failed or was cancelled.
2424
echo Right-click this file and choose "Run as administrator".
25-
echo Or check User Account Control (UAC) settings.
25+
echo Or check User Account Control settings.
2626
echo.
2727
pause
2828
exit /b 1
@@ -450,26 +450,14 @@ if not exist "%SYSINT_DIR%" (
450450
)
451451
)
452452

453-
:: Download using PowerShell with progress
453+
:: Download using PowerShell
454454
echo Downloading Sysinternals Suite...
455455
echo This may take 1-3 minutes depending on your connection.
456456
echo.
457457

458-
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
459-
"$ProgressPreference = 'SilentlyContinue'; " ^
460-
"try { " ^
461-
" Write-Host 'Connecting to download server...' -ForegroundColor Cyan; " ^
462-
" $webClient = New-Object System.Net.WebClient; " ^
463-
" $webClient.DownloadFile('%DOWNLOAD_URL%', '%ZIP_FILE%'); " ^
464-
" Write-Host 'Download completed successfully!' -ForegroundColor Green; " ^
465-
" exit 0; " ^
466-
"} catch { " ^
467-
" Write-Host 'ERROR: Download failed!' -ForegroundColor Red; " ^
468-
" Write-Host $_.Exception.Message -ForegroundColor Red; " ^
469-
" exit 1; " ^
470-
"}"
458+
powershell -NoProfile -ExecutionPolicy Bypass -Command "& { $ProgressPreference='SilentlyContinue'; Write-Host 'Connecting to download server...' -ForegroundColor Cyan; Invoke-WebRequest -Uri '%DOWNLOAD_URL%' -OutFile '%ZIP_FILE%' -UseBasicParsing; if (Test-Path '%ZIP_FILE%') { Write-Host 'Download completed successfully!' -ForegroundColor Green; exit 0 } else { Write-Host 'Download failed!' -ForegroundColor Red; exit 1 } }"
471459

472-
if errorlevel 1 (
460+
if not exist "%ZIP_FILE%" (
473461
echo.
474462
echo [ERROR] Download failed. Please check:
475463
echo - Internet connection
@@ -508,31 +496,7 @@ echo --------------------------------------------------------
508496
echo.
509497

510498
:: Extract ZIP using PowerShell
511-
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
512-
"try { " ^
513-
" Write-Host 'Extracting files to: %SYSINT_DIR%' -ForegroundColor Cyan; " ^
514-
" Add-Type -AssemblyName System.IO.Compression.FileSystem; " ^
515-
" [System.IO.Compression.ZipFile]::ExtractToDirectory('%ZIP_FILE%', '%SYSINT_DIR%'); " ^
516-
" Write-Host 'Extraction completed successfully!' -ForegroundColor Green; " ^
517-
" exit 0; " ^
518-
"} catch { " ^
519-
" if ($_.Exception.Message -match 'already exists') { " ^
520-
" Write-Host 'Files exist, overwriting...' -ForegroundColor Yellow; " ^
521-
" $zip = [System.IO.Compression.ZipFile]::OpenRead('%ZIP_FILE%'); " ^
522-
" foreach ($entry in $zip.Entries) { " ^
523-
" $dest = Join-Path '%SYSINT_DIR%' $entry.FullName; " ^
524-
" if ($entry.FullName -like '*/') { continue; } " ^
525-
" [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $dest, $true); " ^
526-
" } " ^
527-
" $zip.Dispose(); " ^
528-
" Write-Host 'Overwrite completed!' -ForegroundColor Green; " ^
529-
" exit 0; " ^
530-
" } else { " ^
531-
" Write-Host 'ERROR: Extraction failed!' -ForegroundColor Red; " ^
532-
" Write-Host $_.Exception.Message -ForegroundColor Red; " ^
533-
" exit 1; " ^
534-
" } " ^
535-
"}"
499+
powershell -NoProfile -ExecutionPolicy Bypass -Command "& { Write-Host 'Extracting files to: %SYSINT_DIR%' -ForegroundColor Cyan; Expand-Archive -Path '%ZIP_FILE%' -DestinationPath '%SYSINT_DIR%' -Force; if (Test-Path '%SYSINT_DIR%\psinfo.exe') { Write-Host 'Extraction completed successfully!' -ForegroundColor Green } else { Write-Host 'Extraction may have failed!' -ForegroundColor Yellow } }"
536500

537501
if errorlevel 1 (
538502
echo.

0 commit comments

Comments
 (0)