Files
claudetools/CTONW_ANALYSIS.md
Mike Swanson 3faf09c111 feat: Complete DOS update system with test data routing fix
Implemented comprehensive DOS 6.22 update system for ~30 test stations with
critical fix for test data database import routing.

## Major Changes

### DOS Batch Files (7 files)
- NWTOC.BAT: Download updates from network to DOS machines
- CTONW.BAT v1.2: Upload with separate ProdSW/LOGS routing (CRITICAL FIX)
- UPDATE.BAT: Full system backup to network
- STAGE.BAT: System file staging for safe updates
- REBOOT.BAT: Apply staged updates on reboot
- CHECKUPD.BAT: Check for available updates
- DEPLOY.BAT: One-time deployment installer for DOS machines

### CTONW v1.2 Critical Fix
Fixed test data routing to match AD2 sync script expectations:
- Software distribution: C:\ATE\*.EXE -> T:\TS-4R\ProdSW\ (bidirectional)
- Test data logging: C:\ATE\8BDATA\*.DAT -> T:\TS-4R\LOGS\8BLOG\ (upload only)
- Subdirectory mapping: 8BDATA->8BLOG, DSCDATA->DSCLOG, HVDATA->HVLOG, etc.
- Test data now correctly imported to AD2 database via Sync-FromNAS.ps1

### Deployment Infrastructure
- copy-to-ad2.ps1: Automated deployment to AD2 server
- DOS_DEPLOYMENT_GUIDE.md: Complete deployment documentation
- DEPLOYMENT_GUIDE.md: Technical workflow documentation
- credentials.md: Centralized credentials (AD2, NAS, Gitea)

### Analysis & Documentation (15 files)
- CTONW_ANALYSIS.md: Comprehensive compliance analysis
- CTONW_V1.2_CHANGELOG.md: Detailed v1.2 changes
- NWTOC_ANALYSIS.md: Download workflow analysis
- DOS_BATCH_ANALYSIS.md: DOS 6.22 compatibility guide
- UPDATE_WORKFLOW.md: Backup system workflow
- BEHAVIORAL_RULES_INTEGRATION_SUMMARY.md: C: drive integration

### Session Logs
- session-logs/2026-01-19-session.md: Complete session documentation

### Conversation Reorganization
- Cleaned up 156 imported conversation files
- Organized into sessions-by-date structure
- Created metadata index and large files guide

## Technical Details

### AD2 → NAS → DOS Sync Flow
1. Admin copies files to AD2: \192.168.0.6\C$\Shares\test\
2. Sync-FromNAS.ps1 runs every 15 minutes (AD2 → NAS)
3. DOS machines access via T: drive (\D2TESTNAS\test)
4. NWTOC downloads updates, CTONW uploads test data
5. Sync imports test data to AD2 database

### DOS 6.22 Compatibility
- No %COMPUTERNAME%, uses %MACHINE% variable
- No IF /I, uses multiple case-specific checks
- Proper ERRORLEVEL checking (highest values first)
- XCOPY /S for subdirectory support
- ASCII markers ([OK], [ERROR], [WARNING]) instead of emojis

### File Locations
- AD2: C:\Shares\test\COMMON\ProdSW\ (deployed)
- NAS: T:\COMMON\ProdSW\ (synced)
- DOS: C:\BAT\ (installed)
- Logs: T:\TS-4R\LOGS\8BLOG\ (test data for database import)

## Deployment Status

 All 7 batch files deployed to AD2 (both COMMON and _COMMON)
 Pending sync to NAS (within 15 minutes)
 Pending pilot deployment on TS-4R
📋 Ready for rollout to ~30 DOS machines

## Breaking Changes

CTONW v1.1 → v1.2: Test data now uploads to LOGS folder instead of ProdSW.
Existing machines must download v1.2 via NWTOC for proper database import.

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

11 KiB

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

DOS 6.22 Compatibility - PASS

  • No %COMPUTERNAME% variable (uses %MACHINE% instead)
  • No IF /I (uses case-sensitive with multiple checks)
  • Proper ERRORLEVEL checking (highest first: 4, 2, 1)
  • Uses T: 2>NUL for drive testing
  • Uses IF EXIST path\NUL for directory testing
  • DOS-compatible FOR loops
  • No long filenames (8.3 format)
  • No modern Windows features

Examples of proper DOS 6.22 code:

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)

%MACHINE% Variable Usage - PASS

  • Checks if %MACHINE% is set (line 21)
  • Clear error message if not set (lines 24-35)
  • Uses %MACHINE% in paths (line 77: T:\%MACHINE%\ProdSW)
  • Creates machine directory if needed (line 121)

T: Drive Checking - PASS

  • Comprehensive drive checking (lines 43-68)
  • Double-check with NUL device test (line 50)
  • Clear error messages with recovery instructions
  • Suggests STARTNET.BAT or manual NET USE

Error Handling - PASS

  • No machine variable error (lines 22-35)
  • T: drive not available error (lines 54-68)
  • Source directory not found error (lines 107-113)
  • Target directory creation error (lines 205-217)
  • Upload initialization error (lines 219-230)
  • User termination error (lines 232-240)
  • All errors include PAUSE and clear instructions

Console Output - PASS

  • Compact banner (lines 90-98)
  • Clear markers: [OK], [WARNING], [ERROR]
  • Progress indicators: [1/2], [2/2]
  • Not excessively scrolling
  • Shows source and destination paths

Backup Creation - PASS

  • Creates .BAK files on network before overwriting (line 140)
  • Mentions backups in completion message (line 194)

Workflow Alignment - PASS

  • Uploads to correct locations (MACHINE or COMMON)
  • Warns when uploading to COMMON (lines 191-192)
  • Suggests CTONW COMMON for sharing (lines 196-197)
  • Consistent with NWTOC download paths

Issues Found

🔴 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):

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:

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


🟡 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:

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:

: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


🟡 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:

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:

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:

# 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:

  • NWTOC can DOWNLOAD subdirectories from network
  • 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):

  1. Add empty directory checks - Cleaner output

OPTIONAL:

  1. Standardize extension case - Consistency (.BAT not .bat)

Proposed Fix for Issue #1 (Subdirectories)

Replace lines 156-172 with:

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):

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: ⚠️ NEEDS FIXES BEFORE PRODUCTION USE Estimated Fix Time: 15 minutes (simple XCOPY change) Risk Level: LOW (well-structured code, easy to modify)