Issue: DOS 6.22 does not support multi-line IF ( ... ) blocks or
ELSE clauses, causing "Bad command or file name" errors in DEPLOY.BAT
Step 5 (Updating AUTOEXEC.BAT).
Root cause: Parentheses for multi-line IF blocks were added in later
DOS versions. DOS 6.22 only supports single-line IF statements.
Changes:
- Converted IF ( ... ) ELSE ( ... ) to GOTO label structure
- Converted IF ( nested commands ) to GOTO label structure
- Updated check-dos-compatibility.ps1 to detect IF ( ... ) syntax
- Created fix-if-blocks.ps1 automated fix script
Example fix:
BEFORE (DOS error):
IF EXIST file (
command1
command2
) ELSE (
command3
)
AFTER (DOS 6.22 compatible):
IF NOT EXIST file GOTO ELSE_LABEL
command1
command2
GOTO END_LABEL
:ELSE_LABEL
command3
:END_LABEL
Files modified:
- DEPLOY.BAT: Fixed 2 multi-line IF blocks (lines 164, 244)
- Added labels: NO_AUTOEXEC_BACKUP, AUTOEXEC_BACKUP_DONE, ADD_MACHINE_VAR
DOS 6.22 IF syntax:
- Single-line only: IF condition command
- No parentheses: IF condition ( ... )
- No ELSE clause: ) ELSE (
- Use GOTO for multi-step logic
Deployed to:
- D2TESTNAS: /data/test/DEPLOY.BAT (9,848 bytes)
Testing: Should resolve "Bad command or file name" error at Step 5
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
73 lines
3.3 KiB
PowerShell
73 lines
3.3 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='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
|
|
}
|