Skip to content

Commit 7c99bf5

Browse files
committed
fix(bat): real logging and pre-launch checks
- Append elevation line to log only in debug mode - Verify SystemTester.ps1 exists before launching; show clear error - Add -NoExit in debug for interactive and autorun to capture errors
1 parent 8406b5a commit 7c99bf5

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

SystemTester.bat

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ echo.
5555

5656
set "_ELEV_ARGS=/elevated"
5757
if "%ST_DEBUG%"=="1" set "_ELEV_ARGS=/elevated debug"
58-
echo [%DATE% %TIME%] Elevating: "%~f0" %_ELEV_ARGS% ^>^> "%LAUNCH_LOG%"
58+
if "%ST_DEBUG%"=="1" echo [%DATE% %TIME%] Elevating: "%~f0" %_ELEV_ARGS% >> "%LAUNCH_LOG%"
5959
powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -ArgumentList '%_ELEV_ARGS%' -Verb RunAs -WorkingDirectory '%CD%' -WindowStyle Normal"
6060

6161
if errorlevel 1 (
@@ -121,7 +121,9 @@ if "%SCRIPT_PS1%"=="" (
121121

122122
echo Using PowerShell script: %SCRIPT_PS1_NAME%
123123
if "%ST_DEBUG%"=="1" (
124-
echo [%DATE% %TIME%] Using PS1: "%SCRIPT_PS1%" ^(exists: ^<^%SCRIPT_PS1%^^?^) >> "%LAUNCH_LOG%"
124+
set "_EX=NO"
125+
if exist "%SCRIPT_PS1%" set "_EX=YES"
126+
>> "%LAUNCH_LOG%" echo [%DATE% %TIME%] Using PS1: "%SCRIPT_PS1%" (exists: !_EX!)
125127
)
126128
echo.
127129

@@ -738,3 +740,15 @@ echo - energy-report.html (if power test ran)
738740
echo.
739741
pause
740742
exit /b 0
743+
if not exist "%SCRIPT_PS1%" (
744+
echo [ERROR] PowerShell script not found at: %SCRIPT_PS1%
745+
if "%ST_DEBUG%"=="1" >> "%LAUNCH_LOG%" echo [%DATE% %TIME%] ERROR: PS1 missing at "%SCRIPT_PS1%"
746+
pause
747+
goto MENU
748+
)
749+
if not exist "%SCRIPT_PS1%" (
750+
echo [ERROR] PowerShell script not found at: %SCRIPT_PS1%
751+
if "%ST_DEBUG%"=="1" >> "%LAUNCH_LOG%" echo [%DATE% %TIME%] ERROR: PS1 missing at "%SCRIPT_PS1%"
752+
pause
753+
goto MENU
754+
)

0 commit comments

Comments
 (0)