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>
Critical fix for DOS 6.22 compatibility - CRLF line endings were being
converted to LF during AD2-to-NAS sync, causing BAT files to fail on DOS.
Root Cause:
- OpenSSH scp uses SFTP protocol by default (text mode)
- SFTP converts line endings (CRLF → LF)
- DOS 6.22 requires CRLF for batch file execution
Solution - Fixed AD2 Sync Script:
- Added -O flag to scp commands in Sync-FromNAS.ps1
- Forces legacy SCP protocol (binary mode)
- Preserves CRLF line endings during transfer
Created deployment scripts:
- fix-ad2-scp-line-endings.ps1: Updates Sync-FromNAS.ps1 with -O flag
- deploy-all-bat-files.ps1: Deploy 6 BAT files to AD2 (UPDATE, NWTOC,
CTONW, CHECKUPD, REBOOT, DEPLOY)
- deploy-bat-to-nas-direct.ps1: Direct SCP to NAS with -O flag for
immediate testing
- verify-nas-crlf.ps1: Validates CRLF preservation on NAS
Created diagnostic scripts:
- check-line-endings.ps1: Compare original vs NAS file line endings
- check-ad2-sync-log.ps1: Monitor sync log on AD2
- check-ad2-bat-files.ps1: Verify files on AD2
- check-scp-commands.ps1: Analyze SCP command usage
- trigger-ad2-sync-now.ps1: Manual sync trigger for testing
Verification:
- DEPLOY.BAT: 9,753 bytes with CRLF (was 9,408 bytes with LF)
- All 6 BAT files deployed to NAS with CRLF preserved
- DOS machines can now execute batch files from T:\
Files deployed:
- DEPLOY.BAT (one-time installer)
- UPDATE.BAT (backup utility)
- NWTOC.BAT (network to computer updates)
- CTONW.BAT (computer to network uploads)
- CHECKUPD.BAT (check for updates)
- REBOOT.BAT (reboot utility)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>