Skip to content

Commit 8631bcd

Browse files
committed
Handle tool verification exit statuses
1 parent 386d7dc commit 8631bcd

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

SystemTester.bat

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,16 @@ echo.
241241
pause
242242
echo.
243243
:: Call the PowerShell function for tool verification
244-
powershell -NoProfile -ExecutionPolicy Bypass -Command "try { . '%SCRIPT_PS1%'; Test-ToolVerification; exit 0 } catch { Write-Error $_; exit 1 }"
245-
if errorlevel 1 (
246-
echo.
247-
echo [ERROR] Verification encountered an issue. Review output above.
244+
powershell -NoProfile -ExecutionPolicy Bypass -Command "try { . ""%SCRIPT_PS1%""; if (-not (Test-ToolVerification)) { exit 2 } else { exit 0 } } catch { Write-Error $_; exit 1 }"
245+
set "VERIFY_CODE=%errorlevel%"
246+
echo.
247+
if "%VERIFY_CODE%"=="0" (
248+
echo Verification complete. All tools validated successfully.
249+
) else if "%VERIFY_CODE%"=="2" (
250+
echo [WARNING] Verification completed with issues detected. Review output above.
251+
echo Use Menu Option 5 to re-download the Sysinternals Suite.
248252
) else (
249-
echo.
250-
echo Verification complete.
253+
echo [ERROR] Verification encountered an issue. Review output above.
251254
)
252255
echo.
253256
pause

SystemTester.ps1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ function Test-ToolVerification {
119119

120120
foreach ($tool in $allTools) {
121121
$result = Test-ToolIntegrity -ToolName $tool
122+
if (-not $stats.ContainsKey($result.Status)) {
123+
$stats[$result.Status] = 0
124+
}
122125
$stats[$result.Status]++
123126

124127
$color = switch ($result.Status) {
@@ -160,15 +163,28 @@ function Test-ToolVerification {
160163
Write-Host ""
161164

162165
$totalIssues = $stats.BAD_SIZE + $stats.BAD_SIGNATURE + $stats.MISSING + $stats.CHECK_FAILED
163-
if ($totalIssues -eq 0 -and $stats.VALID_MS -gt 0) {
166+
if ($totalIssues -eq 0 -and ($stats.VALID_MS + $stats.VALID_OTHER + $stats.NOT_SIGNED) -gt 0) {
164167
Write-Host "STATUS: All present tools are verified and safe to use" -ForegroundColor Green
165-
} elseif ($totalIssues -gt 0) {
168+
Write-Host ""
169+
return $true
170+
}
171+
172+
if ($totalIssues -gt 0) {
166173
Write-Host "STATUS: $totalIssues issue(s) detected - recommend re-download" -ForegroundColor Yellow
167174
if ($script:LaunchedViaBatch) {
168175
Write-Host "ACTION: Use Batch Menu Option 5 to re-download tools" -ForegroundColor Yellow
169176
}
177+
Write-Host ""
178+
return $false
179+
}
180+
181+
Write-Host "STATUS: No tools were successfully verified" -ForegroundColor Yellow
182+
Write-Host " Ensure Sysinternals Suite is installed" -ForegroundColor Yellow
183+
if ($script:LaunchedViaBatch) {
184+
Write-Host "ACTION: Use Batch Menu Option 5 to download tools" -ForegroundColor Yellow
170185
}
171186
Write-Host ""
187+
return $false
172188
}
173189

174190
# Initialize environment

0 commit comments

Comments
 (0)