Files
claudetools/fix-pause-syntax.ps1
Mike Swanson 3b55cf1312 fix: Replace PAUSE with message syntax (not supported in DOS 6.22)
Issue: DOS 6.22 PAUSE command does not accept message text as parameter.
The syntax "PAUSE message..." is a Windows NT/2000+ feature that causes
command-line parameters (%1, %2, etc.) to be consumed/lost in DOS 6.22.

Root cause: User ran "T:\DEPLOY.BAT TS-4R" but script reported
"Machine name not provided". The parameter %1 was being consumed by
the invalid PAUSE syntax at line 31 before reaching GET_MACHINE_NAME.

Changes:
- Fixed 46 PAUSE commands across 9 BAT files
- Converted "PAUSE message..." to "ECHO message..." + "PAUSE"
- Updated check-dos-compatibility.ps1 to detect PAUSE with message
- Created fix-pause-syntax.ps1 automated fix script

Example fix:
BEFORE (Windows NT+ syntax, causes parameter loss):
  PAUSE Press any key to continue...

AFTER (DOS 6.22 compatible):
  ECHO Press any key to continue...
  PAUSE

DOS 6.22 PAUSE command:
- Syntax: PAUSE (no parameters)
- Displays: "Press any key to continue..."
- Cannot customize message (built-in text only)

Files modified:
- DEPLOY.BAT: 10 PAUSE commands fixed
- UPDATE.BAT: 7 PAUSE commands fixed
- CTONW.BAT: 8 PAUSE commands fixed
- NWTOC.BAT: 6 PAUSE commands fixed
- REBOOT.BAT: 4 PAUSE commands fixed
- STAGE.BAT: 6 PAUSE commands fixed
- CHECKUPD.BAT: 2 PAUSE commands fixed
- DOSTEST.BAT: 2 PAUSE commands fixed
- AUTOEXEC.BAT: 1 PAUSE command fixed

Deployed to:
- D2TESTNAS: /data/test/*.BAT (9,908 bytes for DEPLOY.BAT)

Testing: Should now correctly receive command-line parameter:
  T:\DEPLOY.BAT TS-4R

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 17:19:44 -07:00

62 lines
1.9 KiB
PowerShell

# Fix PAUSE command syntax - DOS 6.22 does not accept message parameters
# Convert "PAUSE message..." to "ECHO message..." followed by "PAUSE"
$BATFiles = Get-ChildItem *.BAT | Where-Object {
$_.Name -notlike "*_FROM_*" -and
$_.Name -notlike "*_TEST*" -and
$_.Name -notlike "*_VERIFY*" -and
$_.Name -notlike "*_CHECK*" -and
$_.Name -notlike "*_MONITOR*"
}
Write-Host "[INFO] Fixing PAUSE syntax (DOS 6.22 does not accept message)" -ForegroundColor Cyan
Write-Host ""
$TotalFixed = 0
foreach ($File in $BATFiles) {
Write-Host "Processing: $($File.Name)" -ForegroundColor White
$Lines = Get-Content $File.FullName
$Modified = $false
$NewLines = @()
for ($i = 0; $i -lt $Lines.Count; $i++) {
$Line = $Lines[$i]
# Check if line starts with PAUSE followed by text
if ($Line -match '^(\s*)PAUSE\s+(.+)$') {
$Indent = $Matches[1]
$Message = $Matches[2]
# Replace with ECHO + PAUSE
$NewLines += "${Indent}ECHO $Message"
$NewLines += "${Indent}PAUSE"
$Modified = $true
$TotalFixed++
} else {
$NewLines += $Line
}
}
if ($Modified) {
$NewLines | Set-Content $File.FullName
Write-Host " [OK] Fixed PAUSE syntax" -ForegroundColor Green
} else {
Write-Host " [OK] No PAUSE issues found" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "[SUCCESS] Fixed $TotalFixed PAUSE commands across all files" -ForegroundColor Green
Write-Host ""
Write-Host "DOS 6.22 PAUSE syntax:" -ForegroundColor Cyan
Write-Host " CORRECT:" -ForegroundColor Green
Write-Host " ECHO Press any key to continue..." -ForegroundColor White
Write-Host " PAUSE" -ForegroundColor White
Write-Host ""
Write-Host " INCORRECT (Windows NT/2000+):" -ForegroundColor Red
Write-Host " PAUSE Press any key to continue..." -ForegroundColor Red
Write-Host ""