Files
claudetools/check-dos-compatibility.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

74 lines
3.4 KiB
PowerShell

# Comprehensive DOS 6.22 compatibility checker
# Scans all BAT files for incompatible commands
$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 "========================================" -ForegroundColor Red
Write-Host "DOS 6.22 COMPATIBILITY CHECK" -ForegroundColor Red
Write-Host "========================================" -ForegroundColor Red
Write-Host ""
$TotalIssues = 0
# DOS 6.22 INCOMPATIBLE patterns
$IncompatiblePatterns = @(
@{Pattern='SET\s+/P'; Description='SET /P (interactive input) - NOT in DOS 6.22'},
@{Pattern='SET\s+/A'; Description='SET /A (arithmetic) - NOT in DOS 6.22'},
@{Pattern='IF\s+/I'; Description='IF /I (case-insensitive) - NOT in DOS 6.22'},
@{Pattern='FOR\s+/F'; Description='FOR /F (parse files) - NOT in DOS 6.22'},
@{Pattern='FOR\s+/L'; Description='FOR /L (loop) - NOT in DOS 6.22'},
@{Pattern='FOR\s+/D'; Description='FOR /D (directories) - NOT in DOS 6.22'},
@{Pattern='FOR\s+/R'; Description='FOR /R (recursive) - NOT in DOS 6.22'},
@{Pattern='GOTO\s+:EOF'; Description='GOTO :EOF - NOT in DOS 6.22 (use GOTO END)'},
@{Pattern='%COMPUTERNAME%'; Description='%COMPUTERNAME% - NOT in DOS 6.22'},
@{Pattern='%USERNAME%'; Description='%USERNAME% - NOT in DOS 6.22'},
@{Pattern='%USERPROFILE%'; Description='%USERPROFILE% - NOT in DOS 6.22'},
@{Pattern='&&'; Description='&& operator - NOT in DOS 6.22'},
@{Pattern='\|\|'; Description='|| operator - NOT in DOS 6.22'},
@{Pattern='\\NUL(?!\s|$)'; Description='\NUL as filename - INVALID (use \*.* for directory test)'},
@{Pattern='XCOPY.*\/Q'; Description='XCOPY /Q (quiet mode) - NOT in DOS 6.22'},
@{Pattern='IF.*\('; Description='IF ( ... ) multi-line blocks - NOT in DOS 6.22 (use GOTO labels)'},
@{Pattern='\)\s*ELSE\s*\('; Description=') ELSE ( clause - NOT in DOS 6.22 (use GOTO labels)'},
@{Pattern='^PAUSE\s+'; Description='PAUSE message - NOT in DOS 6.22 (use ECHO then PAUSE)'},
@{Pattern='CHOICE\s+/[A-Z]'; Description='CHOICE with options - Check if CHOICE.COM available'},
@{Pattern='START\s+'; Description='START command - NOT in DOS 6.22'}
)
foreach ($File in $BATFiles) {
Write-Host "Checking: $($File.Name)" -ForegroundColor Cyan
$Content = Get-Content $File.FullName
$FileIssues = 0
foreach ($Pattern in $IncompatiblePatterns) {
$LineNum = 0
foreach ($Line in $Content) {
$LineNum++
if ($Line -match $Pattern.Pattern) {
if ($FileIssues -eq 0) {
Write-Host ""
}
Write-Host " [ERROR] Line $LineNum : $($Pattern.Description)" -ForegroundColor Red
Write-Host " > $Line" -ForegroundColor Yellow
$FileIssues++
$TotalIssues++
}
}
}
if ($FileIssues -eq 0) {
Write-Host " [OK] No incompatibilities found" -ForegroundColor Green
}
Write-Host ""
}
Write-Host "========================================" -ForegroundColor Red
Write-Host "TOTAL ISSUES FOUND: $TotalIssues" -ForegroundColor Red
Write-Host "========================================" -ForegroundColor Red
if ($TotalIssues -gt 0) {
Write-Host ""
Write-Host "ACTION REQUIRED: Fix all incompatibilities before deployment" -ForegroundColor Red
}