Skip to content

Commit 984e329

Browse files
authored
Update SystemTester.bat
adding the ability to download needed sysinterall apps that are needed
1 parent eaa244d commit 984e329

1 file changed

Lines changed: 226 additions & 12 deletions

File tree

SystemTester.bat

Lines changed: 226 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ if not exist "%SCRIPT_DIR%\Sysinternals" (
123123
echo [WARNING] Sysinternals folder not found!
124124
echo Expected location: %SCRIPT_DIR%\Sysinternals\
125125
echo.
126-
echo The script will prompt you to create this folder on first run.
126+
echo You can download the tools automatically using Menu Option 6.
127127
echo.
128128
timeout /t 3 >nul
129129
)
@@ -147,17 +147,18 @@ echo 2. Run ALL Tests Automatically
147147
echo 3. Generate Report from Previous Test Results
148148
echo 4. Fix PowerShell Execution Policy (CurrentUser)
149149
echo 5. Verify Sysinternals Tools Installation
150-
echo 6. Show Help / Troubleshooting
151-
echo 7. Exit
150+
echo 6. Download/Update Sysinternals Suite (Auto)
151+
echo 7. Show Help / Troubleshooting
152+
echo 8. Exit
152153
echo.
153154
echo --------------------------------------------------------
154-
set /p "choice=Choose an option (1-7): "
155+
set /p "choice=Choose an option (1-8): "
155156

156-
:: Validate input is a number between 1-7
157-
echo %choice%| findstr /r "^[1-7]$" >nul 2>&1
157+
:: Validate input is a number between 1-8
158+
echo %choice%| findstr /r "^[1-8]$" >nul 2>&1
158159
if errorlevel 1 (
159160
echo.
160-
echo [ERROR] Invalid choice. Please enter a number between 1 and 7.
161+
echo [ERROR] Invalid choice. Please enter a number between 1 and 8.
161162
timeout /t 2 >nul
162163
goto MENU
163164
)
@@ -167,8 +168,9 @@ if "%choice%"=="2" goto AUTORUN
167168
if "%choice%"=="3" goto REPORT_ONLY
168169
if "%choice%"=="4" goto FIXPOLICY
169170
if "%choice%"=="5" goto VERIFY_TOOLS
170-
if "%choice%"=="6" goto HELP
171-
if "%choice%"=="7" goto EXIT
171+
if "%choice%"=="6" goto DOWNLOAD_TOOLS
172+
if "%choice%"=="7" goto HELP
173+
if "%choice%"=="8" goto EXIT
172174

173175
:: Fallback (should never reach here due to validation)
174176
echo Invalid choice. Please try again.
@@ -367,10 +369,19 @@ if %MISSING% GTR 0 (
367369
echo [WARNING] Some tools are missing.
368370
echo The script will skip tests for missing tools.
369371
echo.
370-
echo To install missing tools:
372+
echo Would you like to download the complete Sysinternals Suite now?
373+
echo.
374+
set /p "download_now=Download automatically? (Y/N): "
375+
if /i "!download_now!"=="Y" (
376+
goto DOWNLOAD_TOOLS
377+
)
378+
echo.
379+
echo To install missing tools manually:
371380
echo 1. Download Sysinternals Suite
372381
echo 2. Extract all .exe files to: %SYSINT_DIR%\
373382
echo.
383+
echo Or use Menu Option 6 to download automatically later.
384+
echo.
374385
) else (
375386
echo [SUCCESS] All key tools are present!
376387
echo You're ready to run tests.
@@ -380,6 +391,204 @@ if %MISSING% GTR 0 (
380391
pause
381392
goto MENU
382393

394+
:DOWNLOAD_TOOLS
395+
echo.
396+
echo ========================================================
397+
echo DOWNLOAD/UPDATE SYSINTERNALS SUITE AUTOMATICALLY
398+
echo ========================================================
399+
echo.
400+
401+
set "SYSINT_DIR=%SCRIPT_DIR%\Sysinternals"
402+
set "DOWNLOAD_URL=https://download.sysinternals.com/files/SysinternalsSuite.zip"
403+
set "ZIP_FILE=%SCRIPT_DIR%\SysinternalsSuite.zip"
404+
405+
echo This will download the latest Sysinternals Suite from:
406+
echo %DOWNLOAD_URL%
407+
echo.
408+
echo Download size: Approximately 30-40 MB
409+
echo.
410+
411+
:: Check if folder exists and has files
412+
if exist "%SYSINT_DIR%\*.exe" (
413+
echo [WARNING] Sysinternals tools already exist in:
414+
echo %SYSINT_DIR%
415+
echo.
416+
echo This will UPDATE/OVERWRITE existing tools.
417+
echo.
418+
set /p "confirm=Continue? (Y/N): "
419+
if /i not "!confirm!"=="Y" (
420+
echo Download cancelled.
421+
timeout /t 2 >nul
422+
goto MENU
423+
)
424+
) else (
425+
echo Target folder: %SYSINT_DIR%
426+
echo.
427+
set /p "confirm=Proceed with download? (Y/N): "
428+
if /i not "!confirm!"=="Y" (
429+
echo Download cancelled.
430+
timeout /t 2 >nul
431+
goto MENU
432+
)
433+
)
434+
435+
echo.
436+
echo --------------------------------------------------------
437+
echo Starting download...
438+
echo --------------------------------------------------------
439+
echo.
440+
441+
:: Create Sysinternals folder if it doesn't exist
442+
if not exist "%SYSINT_DIR%" (
443+
echo Creating folder: %SYSINT_DIR%
444+
mkdir "%SYSINT_DIR%" 2>nul
445+
if errorlevel 1 (
446+
echo [ERROR] Failed to create Sysinternals folder.
447+
echo Check permissions on: %SCRIPT_DIR%
448+
pause
449+
goto MENU
450+
)
451+
)
452+
453+
:: Download using PowerShell with progress
454+
echo Downloading Sysinternals Suite...
455+
echo This may take 1-3 minutes depending on your connection.
456+
echo.
457+
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+
"}"
471+
472+
if errorlevel 1 (
473+
echo.
474+
echo [ERROR] Download failed. Please check:
475+
echo - Internet connection
476+
echo - Firewall/antivirus settings
477+
echo - Proxy configuration
478+
echo.
479+
echo You can manually download from:
480+
echo https://live.sysinternals.com
481+
echo.
482+
pause
483+
goto MENU
484+
)
485+
486+
:: Verify ZIP file was downloaded
487+
if not exist "%ZIP_FILE%" (
488+
echo [ERROR] ZIP file not found after download.
489+
echo Expected: %ZIP_FILE%
490+
pause
491+
goto MENU
492+
)
493+
494+
:: Check ZIP file size (should be at least 10MB)
495+
for %%A in ("%ZIP_FILE%") do set "FILE_SIZE=%%~zA"
496+
if %FILE_SIZE% LSS 10000000 (
497+
echo [WARNING] Downloaded file seems too small (%FILE_SIZE% bytes^)
498+
echo Download may have failed or been corrupted.
499+
del "%ZIP_FILE%" 2>nul
500+
pause
501+
goto MENU
502+
)
503+
504+
echo.
505+
echo --------------------------------------------------------
506+
echo Extracting tools...
507+
echo --------------------------------------------------------
508+
echo.
509+
510+
:: 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+
"}"
536+
537+
if errorlevel 1 (
538+
echo.
539+
echo [ERROR] Extraction failed.
540+
echo You can manually extract the ZIP file:
541+
echo %ZIP_FILE%
542+
echo To folder: %SYSINT_DIR%
543+
echo.
544+
pause
545+
goto MENU
546+
)
547+
548+
:: Clean up ZIP file
549+
echo.
550+
echo Cleaning up...
551+
del "%ZIP_FILE%" 2>nul
552+
553+
echo.
554+
echo --------------------------------------------------------
555+
echo Verifying installation...
556+
echo --------------------------------------------------------
557+
echo.
558+
559+
:: Count installed tools
560+
set "TOOL_COUNT=0"
561+
for %%F in ("%SYSINT_DIR%\*.exe") do (
562+
set /a TOOL_COUNT+=1
563+
)
564+
565+
if %TOOL_COUNT% GTR 0 (
566+
echo [SUCCESS] Installation complete!
567+
echo %TOOL_COUNT% Sysinternals tools installed.
568+
echo.
569+
echo Location: %SYSINT_DIR%
570+
echo.
571+
echo Key tools installed:
572+
for %%t in (psinfo.exe coreinfo.exe pslist.exe handle.exe du.exe streams.exe autorunsc.exe clockres.exe) do (
573+
if exist "%SYSINT_DIR%\%%t" (
574+
echo [OK] %%t
575+
)
576+
)
577+
echo.
578+
echo You can now run tests using Menu Option 1 or 2.
579+
) else (
580+
echo [WARNING] No .exe files found in Sysinternals folder.
581+
echo Installation may have failed.
582+
echo.
583+
echo Please try:
584+
echo - Running this option again
585+
echo - Downloading manually from https://live.sysinternals.com
586+
)
587+
588+
echo.
589+
pause
590+
goto MENU
591+
383592
:HELP
384593
cls
385594
echo ========================================================
@@ -411,8 +620,13 @@ echo 3. SYSINTERNALS TOOLS NOT FOUND
411620
echo --------------------------------------------------------
412621
echo Error: "Sysinternals folder not found" or tools skipped
413622
echo.
414-
echo Solution:
415-
echo - Use Menu Option 5 to verify installation
623+
echo Solution A (AUTOMATIC - RECOMMENDED):
624+
echo - Use Menu Option 6 to download automatically
625+
echo - Downloads latest version from Microsoft
626+
echo - Extracts all tools automatically
627+
echo.
628+
echo Solution B (MANUAL):
629+
echo - Use Menu Option 5 to verify what's missing
416630
echo - Download from: https://live.sysinternals.com
417631
echo - Extract all .exe files to: %SCRIPT_DIR%\Sysinternals\
418632
echo.

0 commit comments

Comments
 (0)