Issue: User reported "[ERROR] MACHINE variable not set" during boot, even though DEPLOY.BAT successfully added SET MACHINE=TS-4R to AUTOEXEC.BAT. Root cause: Using >> operator APPENDS to END of AUTOEXEC.BAT. If any scripts, CALL commands, or other code runs before the end of AUTOEXEC.BAT (like STARTNET.BAT, UPDATE.BAT, or other network/backup scripts), the MACHINE variable is not yet set when those scripts run. Solution: INSERT SET MACHINE at LINE 2 (right after @ECHO OFF), ensuring it's set BEFORE any other commands or scripts execute. Implementation: 1. If AUTOEXEC.BAT exists: - Create temp file with @ECHO OFF - Add SET MACHINE=%MACHINE% - Append rest of AUTOEXEC.BAT (excluding duplicate @ECHO OFF) - Replace original with temp file 2. If AUTOEXEC.BAT doesn't exist: - Create new file with @ECHO OFF and SET MACHINE Changes: BEFORE (appended to end): @ECHO OFF ... existing commands ... ... CALL scripts that need MACHINE ... SET MACHINE=TS-4R ← TOO LATE! AFTER (inserted at beginning): @ECHO OFF SET MACHINE=TS-4R ← SET FIRST! ... existing commands ... ... CALL scripts that need MACHINE ... ← MACHINE already set Files modified: - DEPLOY.BAT: Lines 263-287 (ADD_MACHINE_VAR section) - Now creates C:\AUTOEXEC.TMP for safe insertion - Displays: "(Inserted at beginning, before other commands)" Deployed to: D2TESTNAS /data/test/DEPLOY.BAT (10,564 bytes) Testing: After reboot, MACHINE variable should be set before any network/backup scripts run, eliminating "[ERROR] MACHINE variable not set" Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
9.9 KiB
9.9 KiB