# CTONW.BAT Analysis Report **Date:** 2026-01-19 **File:** CTONW.BAT (Computer to Network upload script) **Version:** 1.0 **Size:** 7,137 bytes --- ## Overall Assessment **Status:** MOSTLY COMPLIANT with 3 issues found CTONW.BAT is DOS 6.22 compatible and follows best practices, but has **3 significant issues** that should be addressed before production use. --- ## Compliance Checklist ### [OK] DOS 6.22 Compatibility - PASS - [OK] No `%COMPUTERNAME%` variable (uses `%MACHINE%` instead) - [OK] No `IF /I` (uses case-sensitive with multiple checks) - [OK] Proper ERRORLEVEL checking (highest first: 4, 2, 1) - [OK] Uses `T: 2>NUL` for drive testing - [OK] Uses `IF EXIST path\NUL` for directory testing - [OK] DOS-compatible FOR loops - [OK] No long filenames (8.3 format) - [OK] No modern Windows features **Examples of proper DOS 6.22 code:** ```batch Line 43: T: 2>NUL # Drive test Line 44: IF ERRORLEVEL 1 GOTO NO_T_DRIVE # Proper ERRORLEVEL check Line 50: IF NOT EXIST T:\NUL # Directory test Lines 80-82: Multiple case checks (COMMON, common, Common) ``` ### [OK] %MACHINE% Variable Usage - PASS - [OK] Checks if %MACHINE% is set (line 21) - [OK] Clear error message if not set (lines 24-35) - [OK] Uses %MACHINE% in paths (line 77: `T:\%MACHINE%\ProdSW`) - [OK] Creates machine directory if needed (line 121) ### [OK] T: Drive Checking - PASS - [OK] Comprehensive drive checking (lines 43-68) - [OK] Double-check with NUL device test (line 50) - [OK] Clear error messages with recovery instructions - [OK] Suggests STARTNET.BAT or manual NET USE ### [OK] Error Handling - PASS - [OK] No machine variable error (lines 22-35) - [OK] T: drive not available error (lines 54-68) - [OK] Source directory not found error (lines 107-113) - [OK] Target directory creation error (lines 205-217) - [OK] Upload initialization error (lines 219-230) - [OK] User termination error (lines 232-240) - [OK] All errors include PAUSE and clear instructions ### [OK] Console Output - PASS - [OK] Compact banner (lines 90-98) - [OK] Clear markers: [OK], [WARNING], [ERROR] - [OK] Progress indicators: [1/2], [2/2] - [OK] Not excessively scrolling - [OK] Shows source and destination paths ### [OK] Backup Creation - PASS - [OK] Creates .BAK files on network before overwriting (line 140) - [OK] Mentions backups in completion message (line 194) ### [OK] Workflow Alignment - PASS - [OK] Uploads to correct locations (MACHINE or COMMON) - [OK] Warns when uploading to COMMON (lines 191-192) - [OK] Suggests CTONW COMMON for sharing (lines 196-197) - [OK] Consistent with NWTOC download paths --- ## Issues Found ### [RED] ISSUE 1: Missing Subdirectory Support (CRITICAL) **Severity:** HIGH - Functionality gap **Location:** Lines 156-172 **Problem:** CTONW only copies files from root of `C:\ATE\`, not subdirectories. However, the actual ProdSW structure on AD2 contains subdirectories: ``` TS-XX/ProdSW/ ├── 8BDATA/ │ ├── 8B49.DAT │ ├── 8BMAIN.DAT │ └── ... ├── DSCDATA/ │ ├── DSCFIN.DAT │ └── ... ├── HVDATA/ ├── PWRDATA/ └── RMSDATA/ ``` **Evidence from sync log:** ``` 2026-01-19 12:09:18 : Pushed: TS-1R/ProdSW/8BDATA/8B49.DAT 2026-01-19 12:09:21 : Pushed: TS-1R/ProdSW/8BDATA/8BMAIN(2013-02-15).DAT ``` **Current code (WRONG):** ```batch Line 165: FOR %%F IN (C:\ATE\*.EXE) DO COPY %%F %TARGETDIR%\ /Y >NUL 2>NUL Line 170: FOR %%F IN (C:\ATE\*.DAT) DO COPY %%F %TARGETDIR%\ /Y >NUL 2>NUL ``` This only copies files from `C:\ATE\`, not `C:\ATE\8BDATA\`, etc. **Correct approach:** Should use `XCOPY` with `/S` flag to copy subdirectories: ```batch XCOPY C:\ATE\*.* %TARGETDIR%\ /S /Y /Q ``` **Impact:** - Users cannot upload their test data files in subdirectories - Machine-specific calibration files won't sync - Defeats the purpose of machine-specific uploads **Recommendation:** REPLACE lines 156-172 with XCOPY /S approach --- ### [YELLOW] ISSUE 2: Missing COMMON Upload Confirmation (MEDIUM) **Severity:** MEDIUM - Safety concern **Location:** Lines 191-192 **Problem:** Uploading to COMMON affects ALL ~30 DOS machines, but script doesn't require confirmation. User could accidentally run `CTONW COMMON` and push potentially bad files to all machines. **Current code:** ```batch IF "%TARGET%"=="COMMON" ECHO [WARNING] Files uploaded to COMMON - will affect ALL machines IF "%TARGET%"=="COMMON" ECHO Other machines will receive these files on next NWTOC ``` Only warns AFTER upload completes. **Safer approach:** Add confirmation prompt BEFORE uploading to COMMON: ```batch :CHECK_COMMON_CONFIRM IF NOT "%TARGET%"=="COMMON" GOTO START_UPLOAD ECHO. ECHO [WARNING] You are about to upload to COMMON ECHO. ECHO This will affect ALL machines (%MACHINE% + 29 others) ECHO Other machines will receive these files on next NWTOC ECHO. ECHO Are you sure? (Y/N) CHOICE /C:YN /N IF ERRORLEVEL 2 GOTO CANCELLED IF ERRORLEVEL 1 GOTO START_UPLOAD :CANCELLED ECHO. ECHO Upload cancelled by user ECHO. PAUSE Press any key to exit... GOTO END ``` **Impact:** - Risk of accidentally affecting all machines - No rollback if bad files uploaded to COMMON - Could cause production disruption **Recommendation:** ADD confirmation prompt before COMMON uploads --- ### [YELLOW] ISSUE 3: Empty Directory Handling (LOW) **Severity:** LOW - Error messages without failure **Location:** Lines 165, 170 **Problem:** FOR loops will show error messages if no matching files found: ```batch FOR %%F IN (C:\ATE\*.EXE) DO COPY %%F %TARGETDIR%\ /Y >NUL 2>NUL FOR %%F IN (C:\ATE\*.DAT) DO COPY %%F %TARGETDIR%\ /Y >NUL 2>NUL ``` If `C:\ATE\` has no .EXE or .DAT files, FOR loop will fail with "File not found" error before DO clause executes. **Better approach:** Check if files exist first: ```batch IF EXIST C:\ATE\*.EXE ( ECHO Copying programs (.EXE files)... FOR %%F IN (C:\ATE\*.EXE) DO COPY %%F %TARGETDIR%\ /Y >NUL 2>NUL ECHO [OK] Programs uploaded ) ELSE ( ECHO [INFO] No .EXE files to upload ) ``` **Impact:** - Minor: User sees confusing error messages - Doesn't prevent script from working - Just creates noise in output **Recommendation:** ADD existence checks or accept minor error messages --- ## Minor Style Issues (Non-Critical) ### Inconsistent Case in Extensions - Line 140: `*.BAT` (uppercase) - Line 144: `*.bat` (lowercase) DOS is case-insensitive, so this works, but inconsistent style. **Recommendation:** Standardize on uppercase `.BAT` for consistency --- ## Code Quality Assessment ### Strengths: 1. **Excellent error handling** - Every failure mode is caught 2. **Clear documentation** - Good comments and usage examples 3. **User-friendly output** - Clear status messages and progress 4. **Proper DOS 6.22 compatibility** - No modern features 5. **Good variable cleanup** - SET TARGET= at end 6. **Backup creation** - .BAK files before overwriting 7. **Target flexibility** - Supports both MACHINE and COMMON ### Weaknesses: 1. **Missing subdirectory support** - Critical functionality gap 2. **No COMMON confirmation** - Safety concern 3. **Empty directory handling** - Minor error messages --- ## Comparison with NWTOC.BAT NWTOC handles subdirectories correctly: ```batch # NWTOC.BAT line 89: XCOPY T:\COMMON\ProdSW\*.* C:\BAT\ /D /Y /Q # NWTOC.BAT line 111 (machine-specific): XCOPY T:\%MACHINE%\ProdSW\*.* C:\BAT\ /D /Y /Q XCOPY T:\%MACHINE%\ProdSW\*.* C:\ATE\ /D /Y /Q ``` NWTOC copies to both `C:\BAT\` and `C:\ATE\` from network. But CTONW only uploads from `C:\BAT\`, not `C:\ATE\` subdirectories. **This creates an asymmetry:** - [OK] NWTOC can DOWNLOAD subdirectories from network - [ERROR] CTONW cannot UPLOAD subdirectories to network --- ## Testing Recommendations Before production deployment: 1. **Test subdirectory upload:** ``` C:\ATE\8BDATA\TEST.DAT → Should upload to T:\TS-4R\ProdSW\8BDATA\TEST.DAT ``` 2. **Test COMMON confirmation:** ``` CTONW COMMON → Should prompt for confirmation ``` 3. **Test empty directory:** ``` Empty C:\ATE\ → Should handle gracefully ``` 4. **Test with actual machine data:** ``` C:\ATE\8BDATA\ C:\ATE\DSCDATA\ C:\ATE\HVDATA\ etc. ``` --- ## Recommendations Summary ### MUST FIX (Before Production): 1. **Add subdirectory support** - Replace FOR loops with XCOPY /S 2. **Add COMMON confirmation** - Prevent accidental all-machine uploads ### SHOULD FIX (Nice to Have): 3. **Add empty directory checks** - Cleaner output ### OPTIONAL: 4. **Standardize extension case** - Consistency (.BAT not .bat) --- ## Proposed Fix for Issue #1 (Subdirectories) Replace lines 156-172 with: ```batch REM ================================================================== REM STEP 8: Upload programs and data (machine-specific only) REM ================================================================== IF "%TARGET%"=="COMMON" GOTO SKIP_PROGRAMS ECHO [2/2] Uploading programs and data from C:\ATE... REM Check if ATE directory exists IF NOT EXIST C:\ATE\NUL GOTO SKIP_PROGRAMS REM Copy all files and subdirectories from C:\ATE ECHO Copying files and subdirectories... XCOPY C:\ATE\*.* %TARGETDIR%\ /S /Y /Q IF ERRORLEVEL 4 GOTO UPLOAD_ERROR_INIT IF ERRORLEVEL 2 GOTO UPLOAD_ERROR_USER IF ERRORLEVEL 1 ECHO [WARNING] No files found in C:\ATE IF NOT ERRORLEVEL 1 ECHO [OK] Programs and data uploaded GOTO UPLOAD_COMPLETE :SKIP_PROGRAMS ECHO [2/2] Skipping programs/data (COMMON target only gets batch files) ECHO. ``` This single XCOPY command replaces both FOR loops and handles subdirectories. --- ## Proposed Fix for Issue #2 (COMMON Confirmation) Insert after line 84 (after SET TARGETDIR=T:\COMMON\ProdSW): ```batch REM ================================================================== REM STEP 4.5: Confirm COMMON upload REM ================================================================== :CHECK_COMMON_CONFIRM IF NOT "%TARGET%"=="COMMON" GOTO DISPLAY_BANNER ECHO. ECHO ============================================================== ECHO [WARNING] COMMON Upload Confirmation ECHO ============================================================== ECHO. ECHO You are about to upload files to COMMON location. ECHO This will affect ALL ~30 DOS machines at Dataforth. ECHO. ECHO Files will be distributed to all machines on next NWTOC run. ECHO. ECHO Are you sure you want to continue? (Y/N) ECHO. CHOICE /C:YN /N IF ERRORLEVEL 2 GOTO UPLOAD_CANCELLED IF ERRORLEVEL 1 GOTO DISPLAY_BANNER :UPLOAD_CANCELLED ECHO. ECHO [INFO] Upload cancelled by user ECHO. ECHO No files were uploaded. ECHO. PAUSE Press any key to exit... GOTO END REM ================================================================== REM STEP 4: Display upload banner (renumbered) REM ================================================================== :DISPLAY_BANNER ``` --- ## Verdict **CTONW.BAT is 95% ready for production.** The script demonstrates excellent DOS 6.22 compatibility, error handling, and user experience. However, the missing subdirectory support (Issue #1) is a **critical gap** that prevents users from uploading their actual test data. **Action Required:** 1. Fix Issue #1 (subdirectories) - MANDATORY before production 2. Fix Issue #2 (COMMON confirmation) - HIGHLY RECOMMENDED 3. Fix Issue #3 (empty directories) - Optional Once Issue #1 is fixed, CTONW will be fully functional and production-ready. --- **Current Status:** [WARNING] NEEDS FIXES BEFORE PRODUCTION USE **Estimated Fix Time:** 15 minutes (simple XCOPY change) **Risk Level:** LOW (well-structured code, easy to modify)