File created successfully at: C:\Users\MikeSwanson\.claude\plans\clever-wobbling-candle.md

# Plan: Simplify UPDATE.BAT for Dataforth DOS Machines

## Objective
Simplify the UPDATE.BAT script by consolidating commands and removing per-station customization. All machines will receive identical COMMON updates, eliminating the complexity of station-specific software distribution.

## User Requirements
1. **Consolidate commands** - Merge operations that are always used together
2. **Remove individualized update routine** - Eliminate per-station `T:\TS-XX\ProdSW\` updates
3. **All machines get COMMON updates only** - Single source of truth for batch files

## Current State Analysis

**Current UPDATE.BAT (5 commands):**
- `CHECK` - Shows DOS version, lists directories
- `BACKUP` - Backs up to `T:\TS-XX\Backup\`
- `SCRIPTS` - Syncs from BOTH `T:\COMMON\ProdSW\` AND `T:\TS-XX\ProdSW\` ← **Remove this**
- `DOS` - Complex staged update (requires reboot)
- `ALL` - Chains CHECK → BACKUP → SCRIPTS

**Issues:**
- Too many commands for simple workflow
- Station-specific sync adds unnecessary complexity
- Users must remember 5 different commands

## Proposed Solution

### New Command Structure (3 commands)

| New Command | Replaces | What It Does |
|-------------|----------|--------------|
| **STATUS** | CHECK | Quick diagnostic (DOS version, disk space, network check) |
| **UPDATE** | CHECK + BACKUP + SCRIPTS | One-stop update operation |
| **DOS** | DOS | System update (kept separate due to reboot requirement) |

### Key Changes

**1. Remove Station-Specific Sync**
```batch
# BEFORE (line 189-190 of current UPDATE.BAT):
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y
IF EXIST T:\%STATION%\ProdSW\*.BAT COPY T:\%STATION%\ProdSW\*.BAT C:\BAT\ /Y

# AFTER:
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y
REM Station-specific sync removed - all machines use COMMON
```

**2. Optional Station Auto-Detection**
```batch
# Try to detect station from C:\NET\SYSTEM.INI
# Fallback to explicit parameter for backward compatibility
# Allows: T:\UPDATE STATUS (auto-detect)
# Or: T:\UPDATE TS-27 STATUS (explicit)
```

**3. Consolidate CHECK + BACKUP + SCRIPTS into UPDATE**
```batch
# Single command does everything:
# - Quick status check
# - Backup to network
# - Update scripts from COMMON
# No more remembering ALL vs individual commands
```

## Implementation Details

### File to Modify
**Primary:** `\\AD2\test\UPDATE.BAT` (syncs to `/data/test/UPDATE.BAT` on NAS)

### New Command Implementations

#### :STATUS (replaces :CHECK)
- Run `VER` to show DOS version
- Check disk space with `DIR C:\`
- Verify network access (`IF EXIST T:\COMMON`)
- List key directories (C:\ATE, C:\BAT, C:\DOS)
- **Better than CHECK:** Adds network connectivity check and cleaner output

#### :UPDATE (combines :CHECK + :BACKUP + :SCRIPTS)
```batch
:UPDATE
ECHO ====================================
ECHO Updating %STATION%
ECHO ====================================

REM [1/3] Quick status check
ECHO [1/3] Checking system status...
VER
IF NOT EXIST T:\COMMON GOTO ERROR_NETWORK

REM [2/3] Backup
ECHO [2/3] Backing up to T:\%STATION%\Backup\...
IF NOT EXIST T:\%STATION%\Backup MKDIR T:\%STATION%\Backup
XCOPY C:\ATE\*.* T:\%STATION%\Backup\ATE\ /S /E /Y > NUL
XCOPY C:\BAT\*.* T:\%STATION%\Backup\BAT\ /S /E /Y > NUL
COPY C:\CONFIG.SYS T:\%STATION%\Backup\ > NUL
COPY C:\AUTOEXEC.BAT T:\%STATION%\Backup\ > NUL

REM [3/3] Update scripts (COMMON only)
ECHO [3/3] Updating batch files...
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y

ECHO Update Complete!
```

#### :DOS (keep existing logic)
- Staged COMMAND.COM update (unchanged - proven to work)
- Better formatted warnings and progress messages
- Redirect verbose output to NUL for cleaner display

### Parameter Parsing Logic

```batch
@ECHO OFF
REM Try to determine station name and command

REM If only 1 parameter, treat as command and auto-detect station
IF "%2"=="" GOTO TRY_AUTO_DETECT

REM If 2 parameters, assume TS-XX COMMAND format (backward compatible)
SET STATION=%1
SET COMMAND=%2
GOTO PARSE_COMMAND

:TRY_AUTO_DETECT
REM Parse station from C:\NET\SYSTEM.INI (computername=TS-XX)
FOR /F "tokens=2 delims==" %%A IN ('TYPE C:\NET\SYSTEM.INI ^| FIND "computername="') DO SET STATION=%%A
IF "%STATION%"=="" GOTO ERROR_NO_STATION
SET COMMAND=%1
GOTO PARSE_COMMAND

:PARSE_COMMAND
REM Map old commands to new commands for backward compatibility
IF "%COMMAND%"=="STATUS" GOTO STATUS
IF "%COMMAND%"=="status" GOTO STATUS
IF "%COMMAND%"=="CHECK" GOTO STATUS
IF "%COMMAND%"=="check" GOTO STATUS
IF "%COMMAND%"=="UPDATE" GOTO UPDATE
IF "%COMMAND%"=="update" GOTO UPDATE
IF "%COMMAND%"=="ALL" GOTO UPDATE
IF "%COMMAND%"=="all" GOTO UPDATE
IF "%COMMAND%"=="BACKUP" GOTO UPDATE
IF "%COMMAND%"=="backup" GOTO UPDATE
IF "%COMMAND%"=="SCRIPTS" GOTO UPDATE
IF "%COMMAND%"=="scripts" GOTO UPDATE
IF "%COMMAND%"=="DOS" GOTO DOS
IF "%COMMAND%"=="dos" GOTO DOS
GOTO USAGE
```

**Backward Compatibility:**
- Old `CHECK` → Maps to `STATUS`
- Old `BACKUP` → Maps to `UPDATE` (combined operation)
- Old `SCRIPTS` → Maps to `UPDATE` (combined operation)
- Old `ALL` → Maps to `UPDATE` (same purpose)
- Old syntax `UPDATE TS-27 CHECK` still works

## Related File Changes

### NWTOC.BAT Update
**File:** `T:\TS-XX\NWTOC.BAT` (per-station boot script)

**Current Code (lines that need changing):**
```batch
REM 1. Update common batch files (all stations)
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\

REM 2. Update station-specific programs
IF EXIST T:\%STATION%\ProdSW\*.EXE COPY T:\%STATION%\ProdSW\*.EXE C:\ATE\
IF EXIST T:\%STATION%\ProdSW\*.BAT COPY T:\%STATION%\ProdSW\*.BAT C:\BAT\
```

**New Code:**
```batch
REM Update common batch files (all stations)
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y

REM Station-specific sync removed per 2026-01-15 simplification
REM All machines now use identical COMMON updates
```

**Deployment Strategy:**
1. Create `T:\COMMON\NWTOC-TEMPLATE.BAT` with new code
2. Use TODO.BAT mechanism to update each station:
   ```batch
   @ECHO OFF
   REM TODO.BAT - Update NWTOC.BAT
   ECHO Updating NWTOC.BAT for %1...
   COPY T:\COMMON\NWTOC-TEMPLATE.BAT C:\BAT\NWTOC.BAT /Y
   COPY T:\COMMON\NWTOC-TEMPLATE.BAT T:\%1\NWTOC.BAT /Y
   ECHO Done
   ```
3. Deploy via sync system (auto-executes on next boot)

### AD2 Sync Script (No Changes Required)
`C:\Shares\test\scripts\Sync-FromNAS.ps1` already syncs:
- `UPDATE.BAT` (root level) ✓ Already added Jan 15
- `COMMON/ProdSW/*` ✓ Already syncing
- `TS-XX/ProdSW/*` - Can remain but unused (won't break anything)

## Deployment Plan

### Phase 1: Update UPDATE.BAT
1. Create new simplified UPDATE.BAT on AD2 at `C:\Shares\test\UPDATE.BAT`
2. Verify DOS line endings (CR+LF): `unix2dos UPDATE.BAT` or `sed -i 's/$/\r/' UPDATE.BAT`
3. Test syntax: Review batch file for DOS 6.22 compatibility
4. Sync to NAS (automatic within 15 minutes, or manual trigger)

### Phase 2: Test on Single Station
1. Select test machine (TS-27 recommended - used in previous testing)
2. Test all commands:
   ```batch
   T:\UPDATE STATUS
   T:\UPDATE TS-27 STATUS          (backward compat)
   T:\UPDATE UPDATE
   T:\UPDATE TS-27 CHECK           (old command → STATUS)
   T:\UPDATE TS-27 ALL             (old command → UPDATE)
   ```
3. Verify backup created in `T:\TS-27\Backup\`
4. Verify scripts updated from COMMON only (no station-specific)

### Phase 3: Update NWTOC.BAT via TODO.BAT
1. Create `T:\COMMON\NWTOC-TEMPLATE.BAT` with simplified code
2. For each active station (TS-1 through TS-30):
   - Place TODO.BAT in `\\AD2\test\TS-XX\`
   - Wait for sync (15 min) or trigger manually
   - NWTOC.BAT updates on next boot
3. Verify on 2-3 stations before mass deployment

### Phase 4: Documentation & Communication
1. Update engineer documentation
2. Email Engineering team with:
   - Command translation table
   - Rationale for changes
   - New workflow instructions
3. Update monitoring scripts (if they reference old commands)

### Phase 5: Cleanup (Optional, Low Priority)
1. Archive station-specific `T:\TS-XX\ProdSW\` folders
2. Keep for 90 days before deletion
3. Monitor for any unexpected dependencies

## Rollback Plan

If issues arise:
1. **Restore old UPDATE.BAT:**
   ```bash
   # From AD2
   Copy-Item "C:\Shares\test\UPDATE.BAT.backup" "C:\Shares\test\UPDATE.BAT" -Force
   ```
2. **Revert NWTOC.BAT via TODO.BAT:**
   - Deploy TODO.BAT with old NWTOC.BAT code
3. **Sync takes effect:** Within 15 minutes automatically

## Verification & Testing

### Test Cases

**1. STATUS Command**
```batch
T:\UPDATE STATUS
```
**Expected Output:**
- DOS version displayed
- Disk space shown
- Network access confirmed (T: drive OK)
- Key directories listed

**2. UPDATE Command**
```batch
T:\UPDATE UPDATE
```
**Expected Output:**
- Progress indicators (1/3, 2/3, 3/3)
- Backup confirmation
- Scripts updated message
- No errors about missing station-specific folders

**3. Backward Compatibility**
```batch
T:\UPDATE TS-27 CHECK    (should work, maps to STATUS)
T:\UPDATE TS-27 ALL      (should work, maps to UPDATE)
T:\UPDATE TS-27 SCRIPTS  (should work, maps to UPDATE)
```

**4. Auto-Detection**
```batch
T:\UPDATE STATUS         (no station name - should auto-detect)
```
**Expected:** Detects station from C:\NET\SYSTEM.INI

**5. Error Handling**
```batch
T:\UPDATE INVALID        (bad command)
```
**Expected:** Shows usage message

### Success Criteria
- [ ] New UPDATE.BAT deployed to all stations
- [ ] STATUS command works (replaces CHECK)
- [ ] UPDATE command works (combines CHECK+BACKUP+SCRIPTS)
- [ ] DOS command works (unchanged logic)
- [ ] Backward compatibility verified (old commands still work)
- [ ] Auto-detection works on test stations
- [ ] NWTOC.BAT updated to remove station-specific sync
- [ ] No station-specific ProdSW folders accessed
- [ ] All batch files updated from T:\COMMON\ProdSW\ only

## Critical Files

**Files to modify:**
1. `\\AD2\test\UPDATE.BAT` - Main implementation
2. `\\AD2\test\COMMON\NWTOC-TEMPLATE.BAT` - New boot script template
3. `\\AD2\test\TS-XX\TODO.BAT` - Deployment mechanism (temporary, per station)

**Files to reference (read-only):**
- `C:\NET\SYSTEM.INI` - Station name auto-detection source
- `C:\Shares\test\scripts\Sync-FromNAS.ps1` - Sync system (verify UPDATE.BAT included)
- `C:\Users\MikeSwanson\claude-projects\dataforth-dos\DOS_BATCH_FILES.md` - Current implementation

**Documentation to update:**
- `C:\Users\MikeSwanson\claude-projects\dataforth-dos\README.md`
- Engineer handbook / email

## Notes & Considerations

**DOS 6.22 Limitations:**
- No `IF /I` for case-insensitive comparison (duplicate IF statements required)
- Must use DOS line endings (CR+LF)
- 127 character path limit
- Limited error handling primitives

**Station-Specific Folders:**
- `T:\TS-XX\ProdSW\` folders will remain but unused
- No harm in keeping them (backward compatibility, emergency rollback)
- Can be archived after 90-day validation period

**NWTOC.BAT Deployment:**
- Uses TODO.BAT mechanism (one-time execution per station)
- Station must reboot for NWTOC.BAT update to take effect
- Can stagger deployment (not all stations at once)

**Testing Priority:**
1. Test on TS-27 first (previously used for testing)
2. Expand to 3-5 more stations
3. Monitor for 1 week
4. Deploy to remaining stations

## Summary

**Before (Complex):**
- 5 commands: CHECK, BACKUP, SCRIPTS, DOS, ALL
- Station-specific sync from `T:\TS-XX\ProdSW\`
- Confusing command hierarchy

**After (Simplified):**
- 3 commands: STATUS, UPDATE, DOS
- Single source of truth: `T:\COMMON\ProdSW\`
- One primary workflow: `T:\UPDATE UPDATE`
- Auto-detection reduces typing errors
- Backward compatible with old syntax

**Benefits:**
- 60% fewer commands (5→3)
- Eliminates per-station customization complexity
- Clearer workflow (UPDATE is the main command)
- Better error messages and progress indicators
- Maintains proven DOS update mechanism


Perfect! I've written the complete plan to the plan file. Now I need to exit plan mode using ExitPlanMode tool.

According to the instructions:
- Phase 4: Final Plan ✓ COMPLETE (just wrote plan file)
- Phase 5: Call ExitPlanMode ✓ NEXT STEP

I should call ExitPlanMode now. I don't need to request any bash permissions since this is just batch file creation/modification which the user will review.

Let me call ExitPlanMode.


ExitPlanMode

# Plan: Simplify UPDATE.BAT for Dataforth DOS Machines

## Objective
Simplify the UPDATE.BAT script by consolidating commands and removing per-station customization. All machines will receive identical COMMON updates, eliminating the complexity of station-specific software distribution.

## User Requirements
1. **Consolidate commands** - Merge operations that are always used together
2. **Remove individualized update routine** - Eliminate per-station `T:\TS-XX\ProdSW\` updates
3. **All machines get COMMON updates only** - Single source of truth for batch files

## Current State Analysis

**Current UPDATE.BAT (5 commands):**
- `CHECK` - Shows DOS version, lists directories
- `BACKUP` - Backs up to `T:\TS-XX\Backup\`
- `SCRIPTS` - Syncs from BOTH `T:\COMMON\ProdSW\` AND `T:\TS-XX\ProdSW\` ← **Remove this**
- `DOS` - Complex staged update (requires reboot)
- `ALL` - Chains CHECK → BACKUP → SCRIPTS

**Issues:**
- Too many commands for simple workflow
- Station-specific sync adds unnecessary complexity
- Users must remember 5 different commands

## Proposed Solution

### New Command Structure (3 commands)

| New Command | Replaces | What It Does |
|-------------|----------|--------------|
| **STATUS** | CHECK | Quick diagnostic (DOS version, disk space, network check) |
| **UPDATE** | CHECK + BACKUP + SCRIPTS | One-stop update operation |
| **DOS** | DOS | System update (kept separate due to reboot requirement) |

### Key Changes

**1. Remove Station-Specific Sync**
```batch
# BEFORE (line 189-190 of current UPDATE.BAT):
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y
IF EXIST T:\%STATION%\ProdSW\*.BAT COPY T:\%STATION%\ProdSW\*.BAT C:\BAT\ /Y

# AFTER:
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y
REM Station-specific sync removed - all machines use COMMON
```

**2. Optional Station Auto-Detection**
```batch
# Try to detect station from C:\NET\SYSTEM.INI
# Fallback to explicit parameter for backward compatibility
# Allows: T:\UPDATE STATUS (auto-detect)
# Or: T:\UPDATE TS-27 STATUS (explicit)
```

**3. Consolidate CHECK + BACKUP + SCRIPTS into UPDATE**
```batch
# Single command does everything:
# - Quick status check
# - Backup to network
# - Update scripts from COMMON
# No more remembering ALL vs individual commands
```

## Implementation Details

### File to Modify
**Primary:** `\\AD2\test\UPDATE.BAT` (syncs to `/data/test/UPDATE.BAT` on NAS)

### New Command Implementations

#### :STATUS (replaces :CHECK)
- Run `VER` to show DOS version
- Check disk space with `DIR C:\`
- Verify network access (`IF EXIST T:\COMMON`)
- List key directories (C:\ATE, C:\BAT, C:\DOS)
- **Better than CHECK:** Adds network connectivity check and cleaner output

#### :UPDATE (combines :CHECK + :BACKUP + :SCRIPTS)
```batch
:UPDATE
ECHO ====================================
ECHO Updating %STATION%
ECHO ====================================

REM [1/3] Quick status check
ECHO [1/3] Checking system status...
VER
IF NOT EXIST T:\COMMON GOTO ERROR_NETWORK

REM [2/3] Backup
ECHO [2/3] Backing up to T:\%STATION%\Backup\...
IF NOT EXIST T:\%STATION%\Backup MKDIR T:\%STATION%\Backup
XCOPY C:\ATE\*.* T:\%STATION%\Backup\ATE\ /S /E /Y > NUL
XCOPY C:\BAT\*.* T:\%STATION%\Backup\BAT\ /S /E /Y > NUL
COPY C:\CONFIG.SYS T:\%STATION%\Backup\ > NUL
COPY C:\AUTOEXEC.BAT T:\%STATION%\Backup\ > NUL

REM [3/3] Update scripts (COMMON only)
ECHO [3/3] Updating batch files...
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y

ECHO Update Complete!
```

#### :DOS (keep existing logic)
- Staged COMMAND.COM update (unchanged - proven to work)
- Better formatted warnings and progress messages
- Redirect verbose output to NUL for cleaner display

### Parameter Parsing Logic

```batch
@ECHO OFF
REM Try to determine station name and command

REM If only 1 parameter, treat as command and auto-detect station
IF "%2"=="" GOTO TRY_AUTO_DETECT

REM If 2 parameters, assume TS-XX COMMAND format (backward compatible)
SET STATION=%1
SET COMMAND=%2
GOTO PARSE_COMMAND

:TRY_AUTO_DETECT
REM Parse station from C:\NET\SYSTEM.INI (computername=TS-XX)
FOR /F "tokens=2 delims==" %%A IN ('TYPE C:\NET\SYSTEM.INI ^| FIND "computername="') DO SET STATION=%%A
IF "%STATION%"=="" GOTO ERROR_NO_STATION
SET COMMAND=%1
GOTO PARSE_COMMAND

:PARSE_COMMAND
REM Map old commands to new commands for backward compatibility
IF "%COMMAND%"=="STATUS" GOTO STATUS
IF "%COMMAND%"=="status" GOTO STATUS
IF "%COMMAND%"=="CHECK" GOTO STATUS
IF "%COMMAND%"=="check" GOTO STATUS
IF "%COMMAND%"=="UPDATE" GOTO UPDATE
IF "%COMMAND%"=="update" GOTO UPDATE
IF "%COMMAND%"=="ALL" GOTO UPDATE
IF "%COMMAND%"=="all" GOTO UPDATE
IF "%COMMAND%"=="BACKUP" GOTO UPDATE
IF "%COMMAND%"=="backup" GOTO UPDATE
IF "%COMMAND%"=="SCRIPTS" GOTO UPDATE
IF "%COMMAND%"=="scripts" GOTO UPDATE
IF "%COMMAND%"=="DOS" GOTO DOS
IF "%COMMAND%"=="dos" GOTO DOS
GOTO USAGE
```

**Backward Compatibility:**
- Old `CHECK` → Maps to `STATUS`
- Old `BACKUP` → Maps to `UPDATE` (combined operation)
- Old `SCRIPTS` → Maps to `UPDATE` (combined operation)
- Old `ALL` → Maps to `UPDATE` (same purpose)
- Old syntax `UPDATE TS-27 CHECK` still works

## Related File Changes

### NWTOC.BAT Update
**File:** `T:\TS-XX\NWTOC.BAT` (per-station boot script)

**Current Code (lines that need changing):**
```batch
REM 1. Update common batch files (all stations)
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\

REM 2. Update station-specific programs
IF EXIST T:\%STATION%\ProdSW\*.EXE COPY T:\%STATION%\ProdSW\*.EXE C:\ATE\
IF EXIST T:\%STATION%\ProdSW\*.BAT COPY T:\%STATION%\ProdSW\*.BAT C:\BAT\
```

**New Code:**
```batch
REM Update common batch files (all stations)
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y

REM Station-specific sync removed per 2026-01-15 simplification
REM All machines now use identical COMMON updates
```

**Deployment Strategy:**
1. Create `T:\COMMON\NWTOC-TEMPLATE.BAT` with new code
2. Use TODO.BAT mechanism to update each station:
   ```batch
   @ECHO OFF
   REM TODO.BAT - Update NWTOC.BAT
   ECHO Updating NWTOC.BAT for %1...
   COPY T:\COMMON\NWTOC-TEMPLATE.BAT C:\BAT\NWTOC.BAT /Y
   COPY T:\COMMON\NWTOC-TEMPLATE.BAT T:\%1\NWTOC.BAT /Y
   ECHO Done
   ```
3. Deploy via sync system (auto-executes on next boot)

### AD2 Sync Script (No Changes Required)
`C:\Shares\test\scripts\Sync-FromNAS.ps1` already syncs:
- `UPDATE.BAT` (root level) ✓ Already added Jan 15
- `COMMON/ProdSW/*` ✓ Already syncing
- `TS-XX/ProdSW/*` - Can remain but unused (won't break anything)

## Deployment Plan

### Phase 1: Update UPDATE.BAT
1. Create new simplified UPDATE.BAT on AD2 at `C:\Shares\test\UPDATE.BAT`
2. Verify DOS line endings (CR+LF): `unix2dos UPDATE.BAT` or `sed -i 's/$/\r/' UPDATE.BAT`
3. Test syntax: Review batch file for DOS 6.22 compatibility
4. Sync to NAS (automatic within 15 minutes, or manual trigger)

### Phase 2: Test on Single Station
1. Select test machine (TS-27 recommended - used in previous testing)
2. Test all commands:
   ```batch
   T:\UPDATE STATUS
   T:\UPDATE TS-27 STATUS          (backward compat)
   T:\UPDATE UPDATE
   T:\UPDATE TS-27 CHECK           (old command → STATUS)
   T:\UPDATE TS-27 ALL             (old command → UPDATE)
   ```
3. Verify backup created in `T:\TS-27\Backup\`
4. Verify scripts updated from COMMON only (no station-specific)

### Phase 3: Update NWTOC.BAT via TODO.BAT
1. Create `T:\COMMON\NWTOC-TEMPLATE.BAT` with simplified code
2. For each active station (TS-1 through TS-30):
   - Place TODO.BAT in `\\AD2\test\TS-XX\`
   - Wait for sync (15 min) or trigger manually
   - NWTOC.BAT updates on next boot
3. Verify on 2-3 stations before mass deployment

### Phase 4: Documentation & Communication
1. Update engineer documentation
2. Email Engineering team with:
   - Command translation table
   - Rationale for changes
   - New workflow instructions
3. Update monitoring scripts (if they reference old commands)

### Phase 5: Cleanup (Optional, Low Priority)
1. Archive station-specific `T:\TS-XX\ProdSW\` folders
2. Keep for 90 days before deletion
3. Monitor for any unexpected dependencies

## Rollback Plan

If issues arise:
1. **Restore old UPDATE.BAT:**
   ```bash
   # From AD2
   Copy-Item "C:\Shares\test\UPDATE.BAT.backup" "C:\Shares\test\UPDATE.BAT" -Force
   ```
2. **Revert NWTOC.BAT via TODO.BAT:**
   - Deploy TODO.BAT with old NWTOC.BAT code
3. **Sync takes effect:** Within 15 minutes automatically

## Verification & Testing

### Test Cases

**1. STATUS Command**
```batch
T:\UPDATE STATUS
```
**Expected Output:**
- DOS version displayed
- Disk space shown
- Network access confirmed (T: drive OK)
- Key directories listed

**2. UPDATE Command**
```batch
T:\UPDATE UPDATE
```
**Expected Output:**
- Progress indicators (1/3, 2/3, 3/3)
- Backup confirmation
- Scripts updated message
- No errors about missing station-specific folders

**3. Backward Compatibility**
```batch
T:\UPDATE TS-27 CHECK    (should work, maps to STATUS)
T:\UPDATE TS-27 ALL      (should work, maps to UPDATE)
T:\UPDATE TS-27 SCRIPTS  (should work, maps to UPDATE)
```

**4. Auto-Detection**
```batch
T:\UPDATE STATUS         (no station name - should auto-detect)
```
**Expected:** Detects station from C:\NET\SYSTEM.INI

**5. Error Handling**
```batch
T:\UPDATE INVALID        (bad command)
```
**Expected:** Shows usage message

### Success Criteria
- [ ] New UPDATE.BAT deployed to all stations
- [ ] STATUS command works (replaces CHECK)
- [ ] UPDATE command works (combines CHECK+BACKUP+SCRIPTS)
- [ ] DOS command works (unchanged logic)
- [ ] Backward compatibility verified (old commands still work)
- [ ] Auto-detection works on test stations
- [ ] NWTOC.BAT updated to remove station-specific sync
- [ ] No station-specific ProdSW folders accessed
- [ ] All batch files updated from T:\COMMON\ProdSW\ only

## Critical Files

**Files to modify:**
1. `\\AD2\test\UPDATE.BAT` - Main implementation
2. `\\AD2\test\COMMON\NWTOC-TEMPLATE.BAT` - New boot script template
3. `\\AD2\test\TS-XX\TODO.BAT` - Deployment mechanism (temporary, per station)

**Files to reference (read-only):**
- `C:\NET\SYSTEM.INI` - Station name auto-detection source
- `C:\Shares\test\scripts\Sync-FromNAS.ps1` - Sync system (verify UPDATE.BAT included)
- `C:\Users\MikeSwanson\claude-projects\dataforth-dos\DOS_BATCH_FILES.md` - Current implementation

**Documentation to update:**
- `C:\Users\MikeSwanson\claude-projects\dataforth-dos\README.md`
- Engineer handbook / email

## Notes & Considerations

**DOS 6.22 Limitations:**
- No `IF /I` for case-insensitive comparison (duplicate IF statements required)
- Must use DOS line endings (CR+LF)
- 127 character path limit
- Limited error handling primitives

**Station-Specific Folders:**
- `T:\TS-XX\ProdSW\` folders will remain but unused
- No harm in keeping them (backward compatibility, emergency rollback)
- Can be archived after 90-day validation period

**NWTOC.BAT Deployment:**
- Uses TODO.BAT mechanism (one-time execution per station)
- Station must reboot for NWTOC.BAT update to take effect
- Can stagger deployment (not all stations at once)

**Testing Priority:**
1. Test on TS-27 first (previously used for testing)
2. Expand to 3-5 more stations
3. Monitor for 1 week
4. Deploy to remaining stations

## Summary

**Before (Complex):**
- 5 commands: CHECK, BACKUP, SCRIPTS, DOS, ALL
- Station-specific sync from `T:\TS-XX\ProdSW\`
- Confusing command hierarchy

**After (Simplified):**
- 3 commands: STATUS, UPDATE, DOS
- Single source of truth: `T:\COMMON\ProdSW\`
- One primary workflow: `T:\UPDATE UPDATE`
- Auto-detection reduces typing errors
- Backward compatible with old syntax

**Benefits:**
- 60% fewer commands (5→3)
- Eliminates per-station customization complexity
- Clearer workflow (UPDATE is the main command)
- Better error messages and progress indicators
- Maintains proven DOS update mechanism


User has approved your plan. You can now start coding. Start with updating your todo list if applicable

Your plan has been saved to: C:\Users\MikeSwanson\.claude\plans\clever-wobbling-candle.md
You can refer back to it if needed during implementation.

## Approved Plan:
# Plan: Simplify UPDATE.BAT for Dataforth DOS Machines

## Objective
Simplify the UPDATE.BAT script by consolidating commands and removing per-station customization. All machines will receive identical COMMON updates, eliminating the complexity of station-specific software distribution.

## User Requirements
1. **Consolidate commands** - Merge operations that are always used together
2. **Remove individualized update routine** - Eliminate per-station `T:\TS-XX\ProdSW\` updates
3. **All machines get COMMON updates only** - Single source of truth for batch files

## Current State Analysis

**Current UPDATE.BAT (5 commands):**
- `CHECK` - Shows DOS version, lists directories
- `BACKUP` - Backs up to `T:\TS-XX\Backup\`
- `SCRIPTS` - Syncs from BOTH `T:\COMMON\ProdSW\` AND `T:\TS-XX\ProdSW\` ← **Remove this**
- `DOS` - Complex staged update (requires reboot)
- `ALL` - Chains CHECK → BACKUP → SCRIPTS

**Issues:**
- Too many commands for simple workflow
- Station-specific sync adds unnecessary complexity
- Users must remember 5 different commands

## Proposed Solution

### New Command Structure (3 commands)

| New Command | Replaces | What It Does |
|-------------|----------|--------------|
| **STATUS** | CHECK | Quick diagnostic (DOS version, disk space, network check) |
| **UPDATE** | CHECK + BACKUP + SCRIPTS | One-stop update operation |
| **DOS** | DOS | System update (kept separate due to reboot requirement) |

### Key Changes

**1. Remove Station-Specific Sync**
```batch
# BEFORE (line 189-190 of current UPDATE.BAT):
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y
IF EXIST T:\%STATION%\ProdSW\*.BAT COPY T:\%STATION%\ProdSW\*.BAT C:\BAT\ /Y

# AFTER:
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y
REM Station-specific sync removed - all machines use COMMON
```

**2. Optional Station Auto-Detection**
```batch
# Try to detect station from C:\NET\SYSTEM.INI
# Fallback to explicit parameter for backward compatibility
# Allows: T:\UPDATE STATUS (auto-detect)
# Or: T:\UPDATE TS-27 STATUS (explicit)
```

**3. Consolidate CHECK + BACKUP + SCRIPTS into UPDATE**
```batch
# Single command does everything:
# - Quick status check
# - Backup to network
# - Update scripts from COMMON
# No more remembering ALL vs individual commands
```

## Implementation Details

### File to Modify
**Primary:** `\\AD2\test\UPDATE.BAT` (syncs to `/data/test/UPDATE.BAT` on NAS)

### New Command Implementations

#### :STATUS (replaces :CHECK)
- Run `VER` to show DOS version
- Check disk space with `DIR C:\`
- Verify network access (`IF EXIST T:\COMMON`)
- List key directories (C:\ATE, C:\BAT, C:\DOS)
- **Better than CHECK:** Adds network connectivity check and cleaner output

#### :UPDATE (combines :CHECK + :BACKUP + :SCRIPTS)
```batch
:UPDATE
ECHO ====================================
ECHO Updating %STATION%
ECHO ====================================

REM [1/3] Quick status check
ECHO [1/3] Checking system status...
VER
IF NOT EXIST T:\COMMON GOTO ERROR_NETWORK

REM [2/3] Backup
ECHO [2/3] Backing up to T:\%STATION%\Backup\...
IF NOT EXIST T:\%STATION%\Backup MKDIR T:\%STATION%\Backup
XCOPY C:\ATE\*.* T:\%STATION%\Backup\ATE\ /S /E /Y > NUL
XCOPY C:\BAT\*.* T:\%STATION%\Backup\BAT\ /S /E /Y > NUL
COPY C:\CONFIG.SYS T:\%STATION%\Backup\ > NUL
COPY C:\AUTOEXEC.BAT T:\%STATION%\Backup\ > NUL

REM [3/3] Update scripts (COMMON only)
ECHO [3/3] Updating batch files...
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y

ECHO Update Complete!
```

#### :DOS (keep existing logic)
- Staged COMMAND.COM update (unchanged - proven to work)
- Better formatted warnings and progress messages
- Redirect verbose output to NUL for cleaner display

### Parameter Parsing Logic

```batch
@ECHO OFF
REM Try to determine station name and command

REM If only 1 parameter, treat as command and auto-detect station
IF "%2"=="" GOTO TRY_AUTO_DETECT

REM If 2 parameters, assume TS-XX COMMAND format (backward compatible)
SET STATION=%1
SET COMMAND=%2
GOTO PARSE_COMMAND

:TRY_AUTO_DETECT
REM Parse station from C:\NET\SYSTEM.INI (computername=TS-XX)
FOR /F "tokens=2 delims==" %%A IN ('TYPE C:\NET\SYSTEM.INI ^| FIND "computername="') DO SET STATION=%%A
IF "%STATION%"=="" GOTO ERROR_NO_STATION
SET COMMAND=%1
GOTO PARSE_COMMAND

:PARSE_COMMAND
REM Map old commands to new commands for backward compatibility
IF "%COMMAND%"=="STATUS" GOTO STATUS
IF "%COMMAND%"=="status" GOTO STATUS
IF "%COMMAND%"=="CHECK" GOTO STATUS
IF "%COMMAND%"=="check" GOTO STATUS
IF "%COMMAND%"=="UPDATE" GOTO UPDATE
IF "%COMMAND%"=="update" GOTO UPDATE
IF "%COMMAND%"=="ALL" GOTO UPDATE
IF "%COMMAND%"=="all" GOTO UPDATE
IF "%COMMAND%"=="BACKUP" GOTO UPDATE
IF "%COMMAND%"=="backup" GOTO UPDATE
IF "%COMMAND%"=="SCRIPTS" GOTO UPDATE
IF "%COMMAND%"=="scripts" GOTO UPDATE
IF "%COMMAND%"=="DOS" GOTO DOS
IF "%COMMAND%"=="dos" GOTO DOS
GOTO USAGE
```

**Backward Compatibility:**
- Old `CHECK` → Maps to `STATUS`
- Old `BACKUP` → Maps to `UPDATE` (combined operation)
- Old `SCRIPTS` → Maps to `UPDATE` (combined operation)
- Old `ALL` → Maps to `UPDATE` (same purpose)
- Old syntax `UPDATE TS-27 CHECK` still works

## Related File Changes

### NWTOC.BAT Update
**File:** `T:\TS-XX\NWTOC.BAT` (per-station boot script)

**Current Code (lines that need changing):**
```batch
REM 1. Update common batch files (all stations)
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\

REM 2. Update station-specific programs
IF EXIST T:\%STATION%\ProdSW\*.EXE COPY T:\%STATION%\ProdSW\*.EXE C:\ATE\
IF EXIST T:\%STATION%\ProdSW\*.BAT COPY T:\%STATION%\ProdSW\*.BAT C:\BAT\
```

**New Code:**
```batch
REM Update common batch files (all stations)
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y

REM Station-specific sync removed per 2026-01-15 simplification
REM All machines now use identical COMMON updates
```

**Deployment Strategy:**
1. Create `T:\COMMON\NWTOC-TEMPLATE.BAT` with new code
2. Use TODO.BAT mechanism to update each station:
   ```batch
   @ECHO OFF
   REM TODO.BAT - Update NWTOC.BAT
   ECHO Updating NWTOC.BAT for %1...
   COPY T:\COMMON\NWTOC-TEMPLATE.BAT C:\BAT\NWTOC.BAT /Y
   COPY T:\COMMON\NWTOC-TEMPLATE.BAT T:\%1\NWTOC.BAT /Y
   ECHO Done
   ```
3. Deploy via sync system (auto-executes on next boot)

### AD2 Sync Script (No Changes Required)
`C:\Shares\test\scripts\Sync-FromNAS.ps1` already syncs:
- `UPDATE.BAT` (root level) ✓ Already added Jan 15
- `COMMON/ProdSW/*` ✓ Already syncing
- `TS-XX/ProdSW/*` - Can remain but unused (won't break anything)

## Deployment Plan

### Phase 1: Update UPDATE.BAT
1. Create new simplified UPDATE.BAT on AD2 at `C:\Shares\test\UPDATE.BAT`
2. Verify DOS line endings (CR+LF): `unix2dos UPDATE.BAT` or `sed -i 's/$/\r/' UPDATE.BAT`
3. Test syntax: Review batch file for DOS 6.22 compatibility
4. Sync to NAS (automatic within 15 minutes, or manual trigger)

### Phase 2: Test on Single Station
1. Select test machine (TS-27 recommended - used in previous testing)
2. Test all commands:
   ```batch
   T:\UPDATE STATUS
   T:\UPDATE TS-27 STATUS          (backward compat)
   T:\UPDATE UPDATE
   T:\UPDATE TS-27 CHECK           (old command → STATUS)
   T:\UPDATE TS-27 ALL             (old command → UPDATE)
   ```
3. Verify backup created in `T:\TS-27\Backup\`
4. Verify scripts updated from COMMON only (no station-specific)

### Phase 3: Update NWTOC.BAT via TODO.BAT
1. Create `T:\COMMON\NWTOC-TEMPLATE.BAT` with simplified code
2. For each active station (TS-1 through TS-30):
   - Place TODO.BAT in `\\AD2\test\TS-XX\`
   - Wait for sync (15 min) or trigger manually
   - NWTOC.BAT updates on next boot
3. Verify on 2-3 stations before mass deployment

### Phase 4: Documentation & Communication
1. Update engineer documentation
2. Email Engineering team with:
   - Command translation table
   - Rationale for changes
   - New workflow instructions
3. Update monitoring scripts (if they reference old commands)

### Phase 5: Cleanup (Optional, Low Priority)
1. Archive station-specific `T:\TS-XX\ProdSW\` folders
2. Keep for 90 days before deletion
3. Monitor for any unexpected dependencies

## Rollback Plan

If issues arise:
1. **Restore old UPDATE.BAT:**
   ```bash
   # From AD2
   Copy-Item "C:\Shares\test\UPDATE.BAT.backup" "C:\Shares\test\UPDATE.BAT" -Force
   ```
2. **Revert NWTOC.BAT via TODO.BAT:**
   - Deploy TODO.BAT with old NWTOC.BAT code
3. **Sync takes effect:** Within 15 minutes automatically

## Verification & Testing

### Test Cases

**1. STATUS Command**
```batch
T:\UPDATE STATUS
```
**Expected Output:**
- DOS version displayed
- Disk space shown
- Network access confirmed (T: drive OK)
- Key directories listed

**2. UPDATE Command**
```batch
T:\UPDATE UPDATE
```
**Expected Output:**
- Progress indicators (1/3, 2/3, 3/3)
- Backup confirmation
- Scripts updated message
- No errors about missing station-specific folders

**3. Backward Compatibility**
```batch
T:\UPDATE TS-27 CHECK    (should work, maps to STATUS)
T:\UPDATE TS-27 ALL      (should work, maps to UPDATE)
T:\UPDATE TS-27 SCRIPTS  (should work, maps to UPDATE)
```

**4. Auto-Detection**
```batch
T:\UPDATE STATUS         (no station name - should auto-detect)
```
**Expected:** Detects station from C:\NET\SYSTEM.INI

**5. Error Handling**
```batch
T:\UPDATE INVALID        (bad command)
```
**Expected:** Shows usage message

### Success Criteria
- [ ] New UPDATE.BAT deployed to all stations
- [ ] STATUS command works (replaces CHECK)
- [ ] UPDATE command works (combines CHECK+BACKUP+SCRIPTS)
- [ ] DOS command works (unchanged logic)
- [ ] Backward compatibility verified (old commands still work)
- [ ] Auto-detection works on test stations
- [ ] NWTOC.BAT updated to remove station-specific sync
- [ ] No station-specific ProdSW folders accessed
- [ ] All batch files updated from T:\COMMON\ProdSW\ only

## Critical Files

**Files to modify:**
1. `\\AD2\test\UPDATE.BAT` - Main implementation
2. `\\AD2\test\COMMON\NWTOC-TEMPLATE.BAT` - New boot script template
3. `\\AD2\test\TS-XX\TODO.BAT` - Deployment mechanism (temporary, per station)

**Files to reference (read-only):**
- `C:\NET\SYSTEM.INI` - Station name auto-detection source
- `C:\Shares\test\scripts\Sync-FromNAS.ps1` - Sync system (verify UPDATE.BAT included)
- `C:\Users\MikeSwanson\claude-projects\dataforth-dos\DOS_BATCH_FILES.md` - Current implementation

**Documentation to update:**
- `C:\Users\MikeSwanson\claude-projects\dataforth-dos\README.md`
- Engineer handbook / email

## Notes & Considerations

**DOS 6.22 Limitations:**
- No `IF /I` for case-insensitive comparison (duplicate IF statements required)
- Must use DOS line endings (CR+LF)
- 127 character path limit
- Limited error handling primitives

**Station-Specific Folders:**
- `T:\TS-XX\ProdSW\` folders will remain but unused
- No harm in keeping them (backward compatibility, emergency rollback)
- Can be archived after 90-day validation period

**NWTOC.BAT Deployment:**
- Uses TODO.BAT mechanism (one-time execution per station)
- Station must reboot for NWTOC.BAT update to take effect
- Can stagger deployment (not all stations at once)

**Testing Priority:**
1. Test on TS-27 first (previously used for testing)
2. Expand to 3-5 more stations
3. Monitor for 1 week
4. Deploy to remaining stations

## Summary

**Before (Complex):**
- 5 commands: CHECK, BACKUP, SCRIPTS, DOS, ALL
- Station-specific sync from `T:\TS-XX\ProdSW\`
- Confusing command hierarchy

**After (Simplified):**
- 3 commands: STATUS, UPDATE, DOS
- Single source of truth: `T:\COMMON\ProdSW\`
- One primary workflow: `T:\UPDATE UPDATE`
- Auto-detection reduces typing errors
- Backward compatible with old syntax

**Benefits:**
- 60% fewer commands (5→3)
- Eliminates per-station customization complexity
- Clearer workflow (UPDATE is the main command)
- Better error messages and progress indicators
- Maintains proven DOS update mechanism


Great! The plan has been approved and I've exited plan mode. Now I should start implementing. Let me set up a todo list to track the implementation phases.

Based on the plan, I need to:

1. Create new simplified UPDATE.BAT
2. Create NWTOC-TEMPLATE.BAT
3. Create TODO.BAT for deploying NWTOC updates
4. Verify DOS line endings
5. Deploy to AD2
6. Test on TS-27

Let me start with the todo list, then begin implementation.


Perfect! The plan is approved. Let me create a todo list to track the implementation.


TodoWrite

Create simplified UPDATE.BAT with 3 commands (STATUS, UPDATE, DOS)

Create NWTOC-TEMPLATE.BAT without station-specific sync

Create TODO.BAT for NWTOC deployment

Verify DOS line endings (CR+LF) on all batch files

Deploy UPDATE.BAT to AD2 and sync to NAS

Test on TS-27 (STATUS, UPDATE, backward compat)


Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable

Create simplified UPDATE.BAT with 3 commands (STATUS, UPDATE, DOS)

Create NWTOC-TEMPLATE.BAT without station-specific sync

Create TODO.BAT for NWTOC deployment

Verify DOS line endings (CR+LF) on all batch files

Deploy UPDATE.BAT to AD2 and sync to NAS

Test on TS-27 (STATUS, UPDATE, backward compat)


Now I'll create the simplified UPDATE.BAT file. I need to make sure I implement all the features from the plan:

1. Parameter parsing with auto-detection
2. Three main commands: STATUS, UPDATE, DOS
3. Backward compatibility mapping
4. Remove station-specific sync
5. Progress indicators
6. Better error handling

Let me write the complete UPDATE.BAT file now.


Now I'll create the simplified UPDATE.BAT. Let me write the complete batch file with all the features from the plan.


Write

@ECHO OFF
REM ============================================================================
REM UPDATE.BAT - Simplified DOS Test Machine Update Utility
REM ============================================================================
REM Version: 2.0 (2026-01-15)
REM Changes: Consolidated commands, removed station-specific sync
REM
REM Usage:
REM   UPDATE STATUS              (auto-detect station)
REM   UPDATE UPDATE              (auto-detect station)
REM   UPDATE DOS                 (auto-detect station)
REM   UPDATE TS-XX STATUS        (explicit station - backward compatible)
REM   UPDATE TS-XX UPDATE        (explicit station - backward compatible)
REM   UPDATE TS-XX DOS           (explicit station - backward compatible)
REM
REM Old Commands (backward compatible):
REM   UPDATE TS-XX CHECK         (maps to STATUS)
REM   UPDATE TS-XX BACKUP        (maps to UPDATE)
REM   UPDATE TS-XX SCRIPTS       (maps to UPDATE)
REM   UPDATE TS-XX ALL           (maps to UPDATE)
REM ============================================================================

REM ============================================================================
REM Parameter Parsing
REM ============================================================================

REM If no parameters, show usage
IF "%1"=="" GOTO USAGE

REM If only 1 parameter, treat as command and try auto-detect station
IF "%2"=="" GOTO TRY_AUTO_DETECT

REM If 2 parameters, assume TS-XX COMMAND format (backward compatible)
SET STATION=%1
SET COMMAND=%2
GOTO PARSE_COMMAND

:TRY_AUTO_DETECT
REM Try to detect station name from C:\NET\SYSTEM.INI
IF NOT EXIST C:\NET\SYSTEM.INI GOTO ERROR_NO_SYSTEM_INI

REM Parse computername= from SYSTEM.INI
FOR /F "tokens=2 delims==" %%A IN ('TYPE C:\NET\SYSTEM.INI ^| FIND "computername="') DO SET STATION=%%A

REM Check if we got a station name
IF "%STATION%"=="" GOTO ERROR_NO_STATION

REM Got station name, use first parameter as command
SET COMMAND=%1
GOTO PARSE_COMMAND

:PARSE_COMMAND
REM Map commands to implementation sections
REM Map new STATUS command
IF "%COMMAND%"=="STATUS" GOTO STATUS
IF "%COMMAND%"=="status" GOTO STATUS

REM Map new UPDATE command
IF "%COMMAND%"=="UPDATE" GOTO UPDATE
IF "%COMMAND%"=="update" GOTO UPDATE

REM Map DOS command (unchanged)
IF "%COMMAND%"=="DOS" GOTO DOS
IF "%COMMAND%"=="dos" GOTO DOS

REM Backward compatibility: Old commands map to new commands
IF "%COMMAND%"=="CHECK" GOTO STATUS
IF "%COMMAND%"=="check" GOTO STATUS
IF "%COMMAND%"=="ALL" GOTO UPDATE
IF "%COMMAND%"=="all" GOTO UPDATE
IF "%COMMAND%"=="BACKUP" GOTO UPDATE
IF "%COMMAND%"=="backup" GOTO UPDATE
IF "%COMMAND%"=="SCRIPTS" GOTO UPDATE
IF "%COMMAND%"=="scripts" GOTO UPDATE

REM Unknown command
GOTO USAGE

REM ============================================================================
REM STATUS Command (replaces CHECK)
REM ============================================================================
:STATUS
ECHO.
ECHO ====================================
ECHO Status Check for %STATION%
ECHO ====================================
ECHO.

REM DOS Version
ECHO DOS Version:
VER
ECHO.

REM Disk Space
ECHO Disk Space (C: drive):
DIR C:\ | FIND "bytes free"
ECHO.

REM Network Access
ECHO Network Access:
IF EXIST T:\COMMON (
    ECHO   T: drive accessible - OK
) ELSE (
    ECHO   T: drive ERROR - Cannot access network
)
ECHO.

REM Key Directories
ECHO Installed Software:
IF EXIST C:\ATE (
    ECHO   C:\ATE - OK
) ELSE (
    ECHO   C:\ATE - NOT FOUND
)
IF EXIST C:\BAT (
    ECHO   C:\BAT - OK
) ELSE (
    ECHO   C:\BAT - NOT FOUND
)
IF EXIST C:\DOS (
    ECHO   C:\DOS - OK
) ELSE (
    ECHO   C:\DOS - NOT FOUND
)
ECHO.

GOTO END

REM ============================================================================
REM UPDATE Command (combines CHECK + BACKUP + SCRIPTS)
REM ============================================================================
:UPDATE
ECHO.
ECHO ====================================
ECHO Updating %STATION%
ECHO ====================================
ECHO.

REM [1/3] Quick status check
ECHO [1/3] Checking system status...
VER

REM Verify network access before proceeding
IF NOT EXIST T:\COMMON GOTO ERROR_NETWORK

ECHO   Network access: OK
ECHO.

REM [2/3] Backup
ECHO [2/3] Backing up to T:\%STATION%\Backup\...

REM Create backup directories if they don't exist
IF NOT EXIST T:\%STATION%\Backup MKDIR T:\%STATION%\Backup
IF NOT EXIST T:\%STATION%\Backup\ATE MKDIR T:\%STATION%\Backup\ATE
IF NOT EXIST T:\%STATION%\Backup\BAT MKDIR T:\%STATION%\Backup\BAT

REM Backup directories (redirect verbose output to NUL)
XCOPY C:\ATE\*.* T:\%STATION%\Backup\ATE\ /S /E /Y > NUL
IF ERRORLEVEL 1 GOTO ERROR_BACKUP
XCOPY C:\BAT\*.* T:\%STATION%\Backup\BAT\ /S /E /Y > NUL
IF ERRORLEVEL 1 GOTO ERROR_BACKUP

REM Backup config files
COPY C:\CONFIG.SYS T:\%STATION%\Backup\ > NUL
COPY C:\AUTOEXEC.BAT T:\%STATION%\Backup\ > NUL

ECHO   Backup complete
ECHO.

REM [3/3] Update scripts (COMMON only - station-specific removed)
ECHO [3/3] Updating batch files...

IF EXIST T:\COMMON\ProdSW\*.BAT (
    COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y
    ECHO   Scripts updated from COMMON
) ELSE (
    ECHO   WARNING: T:\COMMON\ProdSW\ not found
)

ECHO.
ECHO ====================================
ECHO Update Complete!
ECHO ====================================
ECHO.
ECHO If DOS version errors appear, run:
ECHO   T:\UPDATE %STATION% DOS
ECHO.

GOTO END

REM ============================================================================
REM DOS Command (system update - requires reboot)
REM ============================================================================
:DOS
ECHO.
ECHO ====================================
ECHO DOS System Update for %STATION%
ECHO ====================================
ECHO.
ECHO WARNING: This will update DOS system files
ECHO          Machine must reboot to complete
ECHO.
ECHO Files to update:
ECHO   - COMMAND.COM (staged for next boot)
ECHO   - DOS utilities (*.EXE, *.COM, *.SYS)
ECHO.
ECHO Press Ctrl+C to cancel, or
PAUSE
ECHO.

REM Verify DOS files exist on network
IF NOT EXIST T:\COMMON\DOS\COMMAND.COM GOTO ERROR_NO_DOS_FILES

REM Stage COMMAND.COM (can't overwrite while running)
COPY T:\COMMON\DOS\COMMAND.COM C:\COMMAND.NEW > NUL
IF ERRORLEVEL 1 GOTO ERROR_DOS_COPY

REM Backup current AUTOEXEC.BAT
COPY C:\AUTOEXEC.BAT C:\AUTOEXEC.SAV > NUL

REM Create temporary AUTOEXEC.BAT for boot-time update
ECHO @ECHO OFF > C:\AUTOEXEC.BAT
ECHO ECHO Applying DOS update... >> C:\AUTOEXEC.BAT
ECHO COPY C:\COMMAND.NEW C:\DOS\COMMAND.COM >> C:\AUTOEXEC.BAT
ECHO DEL C:\COMMAND.NEW >> C:\AUTOEXEC.BAT
ECHO COPY C:\AUTOEXEC.SAV C:\AUTOEXEC.BAT >> C:\AUTOEXEC.BAT
ECHO DEL C:\AUTOEXEC.SAV >> C:\AUTOEXEC.BAT
ECHO CALL C:\AUTOEXEC.BAT >> C:\AUTOEXEC.BAT

REM Update other DOS files immediately (can be done while running)
COPY T:\COMMON\DOS\*.EXE C:\DOS\ /Y > NUL
COPY T:\COMMON\DOS\*.COM C:\DOS\ /Y > NUL
COPY T:\COMMON\DOS\*.SYS C:\DOS\ /Y > NUL

ECHO DOS files staged for update
ECHO.
ECHO ====================================
ECHO REBOOT NOW to complete the update
ECHO ====================================
ECHO.

GOTO END

REM ============================================================================
REM USAGE - Show help
REM ============================================================================
:USAGE
ECHO.
ECHO ====================================
ECHO UPDATE.BAT - DOS Machine Update Utility
ECHO Version 2.0 (2026-01-15)
ECHO ====================================
ECHO.
ECHO Usage:
ECHO   UPDATE command               (auto-detect station)
ECHO   UPDATE TS-XX command         (explicit station)
ECHO.
ECHO Commands:
ECHO   STATUS    - Check system status and DOS version
ECHO   UPDATE    - Backup machine and update batch files
ECHO   DOS       - Update DOS system files (requires reboot)
ECHO.
ECHO Examples:
ECHO   UPDATE STATUS                (auto-detect station from SYSTEM.INI)
ECHO   UPDATE UPDATE                (auto-detect station)
ECHO   UPDATE TS-27 STATUS          (explicit station)
ECHO   UPDATE TS-27 UPDATE          (explicit station)
ECHO.
ECHO Old Commands (still work):
ECHO   UPDATE TS-27 CHECK           (maps to STATUS)
ECHO   UPDATE TS-27 BACKUP          (maps to UPDATE)
ECHO   UPDATE TS-27 SCRIPTS         (maps to UPDATE)
ECHO   UPDATE TS-27 ALL             (maps to UPDATE)
ECHO.

GOTO END

REM ============================================================================
REM ERROR HANDLERS
REM ============================================================================

:ERROR_NO_SYSTEM_INI
ECHO.
ECHO ERROR: C:\NET\SYSTEM.INI not found
ECHO Cannot auto-detect station name
ECHO.
ECHO Please specify station explicitly:
ECHO   UPDATE TS-XX STATUS
ECHO.
GOTO END

:ERROR_NO_STATION
ECHO.
ECHO ERROR: Could not detect station name from SYSTEM.INI
ECHO.
ECHO Please specify station explicitly:
ECHO   UPDATE TS-XX STATUS
ECHO.
GOTO END

:ERROR_NETWORK
ECHO.
ECHO ERROR: Cannot access T:\COMMON
ECHO Check network connection (T: drive should be mapped to \\D2TESTNAS\test)
ECHO.
ECHO Run: net use T:
ECHO.
GOTO END

:ERROR_BACKUP
ECHO.
ECHO ERROR: Backup failed
ECHO Check network connection and disk space
ECHO.
GOTO END

:ERROR_NO_DOS_FILES
ECHO.
ECHO ERROR: DOS files not found at T:\COMMON\DOS\
ECHO Cannot proceed with DOS update
ECHO.
GOTO END

:ERROR_DOS_COPY
ECHO.
ECHO ERROR: Failed to copy DOS files
ECHO Check disk space on C: drive
ECHO.
GOTO END

REM ============================================================================
REM END
REM ============================================================================
:END


File created successfully at: C:\temp\UPDATE.BAT

@ECHO OFF
REM ============================================================================
REM UPDATE.BAT - Simplified DOS Test Machine Update Utility
REM ============================================================================
REM Version: 2.0 (2026-01-15)
REM Changes: Consolidated commands, removed station-specific sync
REM
REM Usage:
REM   UPDATE STATUS              (auto-detect station)
REM   UPDATE UPDATE              (auto-detect station)
REM   UPDATE DOS                 (auto-detect station)
REM   UPDATE TS-XX STATUS        (explicit station - backward compatible)
REM   UPDATE TS-XX UPDATE        (explicit station - backward compatible)
REM   UPDATE TS-XX DOS           (explicit station - backward compatible)
REM
REM Old Commands (backward compatible):
REM   UPDATE TS-XX CHECK         (maps to STATUS)
REM   UPDATE TS-XX BACKUP        (maps to UPDATE)
REM   UPDATE TS-XX SCRIPTS       (maps to UPDATE)
REM   UPDATE TS-XX ALL           (maps to UPDATE)
REM ============================================================================

REM ============================================================================
REM Parameter Parsing
REM ============================================================================

REM If no parameters, show usage
IF "%1"=="" GOTO USAGE

REM If only 1 parameter, treat as command and try auto-detect station
IF "%2"=="" GOTO TRY_AUTO_DETECT

REM If 2 parameters, assume TS-XX COMMAND format (backward compatible)
SET STATION=%1
SET COMMAND=%2
GOTO PARSE_COMMAND

:TRY_AUTO_DETECT
REM Try to detect station name from C:\NET\SYSTEM.INI
IF NOT EXIST C:\NET\SYSTEM.INI GOTO ERROR_NO_SYSTEM_INI

REM Parse computername= from SYSTEM.INI
FOR /F "tokens=2 delims==" %%A IN ('TYPE C:\NET\SYSTEM.INI ^| FIND "computername="') DO SET STATION=%%A

REM Check if we got a station name
IF "%STATION%"=="" GOTO ERROR_NO_STATION

REM Got station name, use first parameter as command
SET COMMAND=%1
GOTO PARSE_COMMAND

:PARSE_COMMAND
REM Map commands to implementation sections
REM Map new STATUS command
IF "%COMMAND%"=="STATUS" GOTO STATUS
IF "%COMMAND%"=="status" GOTO STATUS

REM Map new UPDATE command
IF "%COMMAND%"=="UPDATE" GOTO UPDATE
IF "%COMMAND%"=="update" GOTO UPDATE

REM Map DOS command (unchanged)
IF "%COMMAND%"=="DOS" GOTO DOS
IF "%COMMAND%"=="dos" GOTO DOS

REM Backward compatibility: Old commands map to new commands
IF "%COMMAND%"=="CHECK" GOTO STATUS
IF "%COMMAND%"=="check" GOTO STATUS
IF "%COMMAND%"=="ALL" GOTO UPDATE
IF "%COMMAND%"=="all" GOTO UPDATE
IF "%COMMAND%"=="BACKUP" GOTO UPDATE
IF "%COMMAND%"=="backup" GOTO UPDATE
IF "%COMMAND%"=="SCRIPTS" GOTO UPDATE
IF "%COMMAND%"=="scripts" GOTO UPDATE

REM Unknown command
GOTO USAGE

REM ============================================================================
REM STATUS Command (replaces CHECK)
REM ============================================================================
:STATUS
ECHO.
ECHO ====================================
ECHO Status Check for %STATION%
ECHO ====================================
ECHO.

REM DOS Version
ECHO DOS Version:
VER
ECHO.

REM Disk Space
ECHO Disk Space (C: drive):
DIR C:\ | FIND "bytes free"
ECHO.

REM Network Access
ECHO Network Access:
IF EXIST T:\COMMON (
    ECHO   T: drive accessible - OK
) ELSE (
    ECHO   T: drive ERROR - Cannot access network
)
ECHO.

REM Key Directories
ECHO Installed Software:
IF EXIST C:\ATE (
    ECHO   C:\ATE - OK
) ELSE (
    ECHO   C:\ATE - NOT FOUND
)
IF EXIST C:\BAT (
    ECHO   C:\BAT - OK
) ELSE (
    ECHO   C:\BAT - NOT FOUND
)
IF EXIST C:\DOS (
    ECHO   C:\DOS - OK
) ELSE (
    ECHO   C:\DOS - NOT FOUND
)
ECHO.

GOTO END

REM ============================================================================
REM UPDATE Command (combines CHECK + BACKUP + SCRIPTS)
REM ============================================================================
:UPDATE
ECHO.
ECHO ====================================
ECHO Updating %STATION%
ECHO ====================================
ECHO.

REM [1/3] Quick status check
ECHO [1/3] Checking system status...
VER

REM Verify network access before proceeding
IF NOT EXIST T:\COMMON GOTO ERROR_NETWORK

ECHO   Network access: OK
ECHO.

REM [2/3] Backup
ECHO [2/3] Backing up to T:\%STATION%\Backup\...

REM Create backup directories if they don't exist
IF NOT EXIST T:\%STATION%\Backup MKDIR T:\%STATION%\Backup
IF NOT EXIST T:\%STATION%\Backup\ATE MKDIR T:\%STATION%\Backup\ATE
IF NOT EXIST T:\%STATION%\Backup\BAT MKDIR T:\%STATION%\Backup\BAT

REM Backup directories (redirect verbose output to NUL)
XCOPY C:\ATE\*.* T:\%STATION%\Backup\ATE\ /S /E /Y > NUL
IF ERRORLEVEL 1 GOTO ERROR_BACKUP
XCOPY C:\BAT\*.* T:\%STATION%\Backup\BAT\ /S /E /Y > NUL
IF ERRORLEVEL 1 GOTO ERROR_BACKUP

REM Backup config files
COPY C:\CONFIG.SYS T:\%STATION%\Backup\ > NUL
COPY C:\AUTOEXEC.BAT T:\%STATION%\Backup\ > NUL

ECHO   Backup complete
ECHO.

REM [3/3] Update scripts (COMMON only - station-specific removed)
ECHO [3/3] Updating batch files...

IF EXIST T:\COMMON\ProdSW\*.BAT (
    COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y
    ECHO   Scripts updated from COMMON
) ELSE (
    ECHO   WARNING: T:\COMMON\ProdSW\ not found
)

ECHO.
ECHO ====================================
ECHO Update Complete!
ECHO ====================================
ECHO.
ECHO If DOS version errors appear, run:
ECHO   T:\UPDATE %STATION% DOS
ECHO.

GOTO END

REM ============================================================================
REM DOS Command (system update - requires reboot)
REM ============================================================================
:DOS
ECHO.
ECHO ====================================
ECHO DOS System Update for %STATION%
ECHO ====================================
ECHO.
ECHO WARNING: This will update DOS system files
ECHO          Machine must reboot to complete
ECHO.
ECHO Files to update:
ECHO   - COMMAND.COM (staged for next boot)
ECHO   - DOS utilities (*.EXE, *.COM, *.SYS)
ECHO.
ECHO Press Ctrl+C to cancel, or
PAUSE
ECHO.

REM Verify DOS files exist on network
IF NOT EXIST T:\COMMON\DOS\COMMAND.COM GOTO ERROR_NO_DOS_FILES

REM Stage COMMAND.COM (can't overwrite while running)
COPY T:\COMMON\DOS\COMMAND.COM C:\COMMAND.NEW > NUL
IF ERRORLEVEL 1 GOTO ERROR_DOS_COPY

REM Backup current AUTOEXEC.BAT
COPY C:\AUTOEXEC.BAT C:\AUTOEXEC.SAV > NUL

REM Create temporary AUTOEXEC.BAT for boot-time update
ECHO @ECHO OFF > C:\AUTOEXEC.BAT
ECHO ECHO Applying DOS update... >> C:\AUTOEXEC.BAT
ECHO COPY C:\COMMAND.NEW C:\DOS\COMMAND.COM >> C:\AUTOEXEC.BAT
ECHO DEL C:\COMMAND.NEW >> C:\AUTOEXEC.BAT
ECHO COPY C:\AUTOEXEC.SAV C:\AUTOEXEC.BAT >> C:\AUTOEXEC.BAT
ECHO DEL C:\AUTOEXEC.SAV >> C:\AUTOEXEC.BAT
ECHO CALL C:\AUTOEXEC.BAT >> C:\AUTOEXEC.BAT

REM Update other DOS files immediately (can be done while running)
COPY T:\COMMON\DOS\*.EXE C:\DOS\ /Y > NUL
COPY T:\COMMON\DOS\*.COM C:\DOS\ /Y > NUL
COPY T:\COMMON\DOS\*.SYS C:\DOS\ /Y > NUL

ECHO DOS files staged for update
ECHO.
ECHO ====================================
ECHO REBOOT NOW to complete the update
ECHO ====================================
ECHO.

GOTO END

REM ============================================================================
REM USAGE - Show help
REM ============================================================================
:USAGE
ECHO.
ECHO ====================================
ECHO UPDATE.BAT - DOS Machine Update Utility
ECHO Version 2.0 (2026-01-15)
ECHO ====================================
ECHO.
ECHO Usage:
ECHO   UPDATE command               (auto-detect station)
ECHO   UPDATE TS-XX command         (explicit station)
ECHO.
ECHO Commands:
ECHO   STATUS    - Check system status and DOS version
ECHO   UPDATE    - Backup machine and update batch files
ECHO   DOS       - Update DOS system files (requires reboot)
ECHO.
ECHO Examples:
ECHO   UPDATE STATUS                (auto-detect station from SYSTEM.INI)
ECHO   UPDATE UPDATE                (auto-detect station)
ECHO   UPDATE TS-27 STATUS          (explicit station)
ECHO   UPDATE TS-27 UPDATE          (explicit station)
ECHO.
ECHO Old Commands (still work):
ECHO   UPDATE TS-27 CHECK           (maps to STATUS)
ECHO   UPDATE TS-27 BACKUP          (maps to UPDATE)
ECHO   UPDATE TS-27 SCRIPTS         (maps to UPDATE)
ECHO   UPDATE TS-27 ALL             (maps to UPDATE)
ECHO.

GOTO END

REM ============================================================================
REM ERROR HANDLERS
REM ============================================================================

:ERROR_NO_SYSTEM_INI
ECHO.
ECHO ERROR: C:\NET\SYSTEM.INI not found
ECHO Cannot auto-detect station name
ECHO.
ECHO Please specify station explicitly:
ECHO   UPDATE TS-XX STATUS
ECHO.
GOTO END

:ERROR_NO_STATION
ECHO.
ECHO ERROR: Could not detect station name from SYSTEM.INI
ECHO.
ECHO Please specify station explicitly:
ECHO   UPDATE TS-XX STATUS
ECHO.
GOTO END

:ERROR_NETWORK
ECHO.
ECHO ERROR: Cannot access T:\COMMON
ECHO Check network connection (T: drive should be mapped to \\D2TESTNAS\test)
ECHO.
ECHO Run: net use T:
ECHO.
GOTO END

:ERROR_BACKUP
ECHO.
ECHO ERROR: Backup failed
ECHO Check network connection and disk space
ECHO.
GOTO END

:ERROR_NO_DOS_FILES
ECHO.
ECHO ERROR: DOS files not found at T:\COMMON\DOS\
ECHO Cannot proceed with DOS update
ECHO.
GOTO END

:ERROR_DOS_COPY
ECHO.
ECHO ERROR: Failed to copy DOS files
ECHO Check disk space on C: drive
ECHO.
GOTO END

REM ============================================================================
REM END
REM ============================================================================
:END


Good! I've created the simplified UPDATE.BAT. Now I need to convert it to DOS line endings (CR+LF). Let me do that using sed.


Now I'll convert to DOS line endings (CR+LF):


Bash

sed -i 's/$/\r/' /c/temp/UPDATE.BAT && file /c/temp/UPDATE.BAT

Convert UPDATE.BAT to DOS line endings


/c/temp/UPDATE.BAT: DOS batch file, ASCII text, with CRLF line terminators


Perfect! The file now has DOS line endings (CRLF). Now let me mark this todo as complete and move to the next one - creating NWTOC-TEMPLATE.BAT.


Perfect! UPDATE.BAT created with DOS line endings. Now let me create the simplified NWTOC-TEMPLATE.BAT.


TodoWrite

Create simplified UPDATE.BAT with 3 commands (STATUS, UPDATE, DOS)

Create NWTOC-TEMPLATE.BAT without station-specific sync

Create TODO.BAT for NWTOC deployment

Verify DOS line endings (CR+LF) on all batch files

Deploy UPDATE.BAT to AD2 and sync to NAS

Test on TS-27 (STATUS, UPDATE, backward compat)


Create TODO.BAT for NWTOC deployment

Create TODO.BAT for NWTOC deployment


Now I need to create NWTOC-TEMPLATE.BAT. This is the boot-time update script that will replace the per-station NWTOC.BAT files. It should:1. Update common batch files from T:\COMMON\ProdSW\
2. Remove the station-specific sync (no more T:\TS-XX\ProdSW\)3. Keep the TODO.BAT mechanism4. Add comments explaining the simplificationLet me create it now.


Write

@ECHO OFF
REM ============================================================================
REM NWTOC.BAT - Network-to-Client Update Script
REM ============================================================================
REM Version: 2.0 (2026-01-15)
REM Changes: Removed station-specific sync - all machines use COMMON updates
REM
REM Usage: NWTOC.BAT TS-XX (called from AUTOEXEC.BAT on boot)
REM
REM This script runs on every boot to download updates from the network
REM ============================================================================

REM Get station name from parameter
SET STATION=%1

REM Verify station parameter provided
IF "%STATION%"=="" GOTO ERROR_NO_STATION

REM ============================================================================
REM Update Common Batch Files (all stations)
REM ============================================================================
IF EXIST T:\COMMON\ProdSW\*.BAT (
    COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y > NUL
)

REM ============================================================================
REM Station-Specific Updates REMOVED (2026-01-15)
REM ============================================================================
REM Previous versions synced from T:\%STATION%\ProdSW\ for per-station
REM customization. This has been simplified - all machines now receive
REM identical updates from T:\COMMON\ProdSW\ only.
REM
REM If station-specific software is needed, use the TODO.BAT mechanism
REM for one-time deployments.

REM ============================================================================
REM TODO.BAT Mechanism (one-time tasks)
REM ============================================================================
REM Check for one-time task file
IF EXIST T:\%STATION%\TODO.BAT (
    REM Execute TODO.BAT with station name as parameter
    CALL T:\%STATION%\TODO.BAT %STATION%

    REM Delete TODO.BAT from network (one-shot execution)
    DEL T:\%STATION%\TODO.BAT
)

GOTO END

REM ============================================================================
REM ERROR HANDLERS
REM ============================================================================

:ERROR_NO_STATION
ECHO ERROR: Station name required
ECHO Usage: NWTOC.BAT TS-XX
GOTO END

REM ============================================================================
REM END
REM ============================================================================
:END


File created successfully at: C:\temp\NWTOC-TEMPLATE.BAT

@ECHO OFF
REM ============================================================================
REM NWTOC.BAT - Network-to-Client Update Script
REM ============================================================================
REM Version: 2.0 (2026-01-15)
REM Changes: Removed station-specific sync - all machines use COMMON updates
REM
REM Usage: NWTOC.BAT TS-XX (called from AUTOEXEC.BAT on boot)
REM
REM This script runs on every boot to download updates from the network
REM ============================================================================

REM Get station name from parameter
SET STATION=%1

REM Verify station parameter provided
IF "%STATION%"=="" GOTO ERROR_NO_STATION

REM ============================================================================
REM Update Common Batch Files (all stations)
REM ============================================================================
IF EXIST T:\COMMON\ProdSW\*.BAT (
    COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y > NUL
)

REM ============================================================================
REM Station-Specific Updates REMOVED (2026-01-15)
REM ============================================================================
REM Previous versions synced from T:\%STATION%\ProdSW\ for per-station
REM customization. This has been simplified - all machines now receive
REM identical updates from T:\COMMON\ProdSW\ only.
REM
REM If station-specific software is needed, use the TODO.BAT mechanism
REM for one-time deployments.

REM ============================================================================
REM TODO.BAT Mechanism (one-time tasks)
REM ============================================================================
REM Check for one-time task file
IF EXIST T:\%STATION%\TODO.BAT (
    REM Execute TODO.BAT with station name as parameter
    CALL T:\%STATION%\TODO.BAT %STATION%

    REM Delete TODO.BAT from network (one-shot execution)
    DEL T:\%STATION%\TODO.BAT
)

GOTO END

REM ============================================================================
REM ERROR HANDLERS
REM ============================================================================

:ERROR_NO_STATION
ECHO ERROR: Station name required
ECHO Usage: NWTOC.BAT TS-XX
GOTO END

REM ============================================================================
REM END
REM ============================================================================
:END


Good! Now convert NWTOC-TEMPLATE.BAT to DOS line endings and mark this todo as complete.


Bash

sed -i 's/$/\r/' /c/temp/NWTOC-TEMPLATE.BAT && file /c/temp/NWTOC-TEMPLATE.BAT

Convert NWTOC-TEMPLATE.BAT to DOS line endings


/c/temp/NWTOC-TEMPLATE.BAT: DOS batch file, ASCII text, with CRLF line terminators


Perfect! Now I need to create a TODO.BAT template that can be used to deploy the new NWTOC.BAT to all stations. This will be placed in each T:\TS-XX\ folder and will execute once on boot.


Now creating the TODO.BAT deployment script:


TodoWrite

Create simplified UPDATE.BAT with 3 commands (STATUS, UPDATE, DOS)

Create NWTOC-TEMPLATE.BAT without station-specific sync

Create TODO.BAT for NWTOC deployment

Verify DOS line endings (CR+LF) on all batch files

Deploy UPDATE.BAT to AD2 and sync to NAS

Test on TS-27 (STATUS, UPDATE, backward compat)


Now I'll create a TODO.BAT template that engineers can copy to each T:\TS-XX\ folder to deploy the new NWTOC.BAT.


Write

@ECHO OFF
REM ============================================================================
REM TODO.BAT - Deploy Updated NWTOC.BAT
REM ============================================================================
REM Purpose: Update NWTOC.BAT to remove station-specific sync
REM Usage: Place this file as T:\TS-XX\TODO.BAT
REM        It will execute once on next boot and auto-delete
REM
REM Instructions for deploying to all stations:
REM   1. Place this file as TODO.BAT in each T:\TS-XX\ folder on AD2
REM   2. Wait for sync (15 min) or trigger manual sync
REM   3. On next boot, each station will update its NWTOC.BAT
REM   4. TODO.BAT will auto-delete after execution
REM ============================================================================

REM Get station name from parameter
SET STATION=%1

ECHO.
ECHO ====================================
ECHO Updating NWTOC.BAT for %STATION%
ECHO ====================================
ECHO.

REM Copy new NWTOC template to local BAT folder
IF EXIST T:\COMMON\NWTOC-TEMPLATE.BAT (
    COPY T:\COMMON\NWTOC-TEMPLATE.BAT C:\BAT\NWTOC.BAT /Y
    ECHO Local NWTOC.BAT updated
) ELSE (
    ECHO ERROR: T:\COMMON\NWTOC-TEMPLATE.BAT not found
    GOTO END
)

REM Also update the network copy (so it matches for future reference)
IF EXIST T:\%STATION%\NWTOC.BAT (
    COPY T:\COMMON\NWTOC-TEMPLATE.BAT T:\%STATION%\NWTOC.BAT /Y
    ECHO Network NWTOC.BAT updated
)

ECHO.
ECHO NWTOC.BAT update complete!
ECHO Station-specific sync removed
ECHO All updates now from T:\COMMON\ProdSW\
ECHO.

:END


File created successfully at: C:\temp\DEPLOY-NWTOC-TODO.BAT

@ECHO OFF
REM ============================================================================
REM TODO.BAT - Deploy Updated NWTOC.BAT
REM ============================================================================
REM Purpose: Update NWTOC.BAT to remove station-specific sync
REM Usage: Place this file as T:\TS-XX\TODO.BAT
REM        It will execute once on next boot and auto-delete
REM
REM Instructions for deploying to all stations:
REM   1. Place this file as TODO.BAT in each T:\TS-XX\ folder on AD2
REM   2. Wait for sync (15 min) or trigger manual sync
REM   3. On next boot, each station will update its NWTOC.BAT
REM   4. TODO.BAT will auto-delete after execution
REM ============================================================================

REM Get station name from parameter
SET STATION=%1

ECHO.
ECHO ====================================
ECHO Updating NWTOC.BAT for %STATION%
ECHO ====================================
ECHO.

REM Copy new NWTOC template to local BAT folder
IF EXIST T:\COMMON\NWTOC-TEMPLATE.BAT (
    COPY T:\COMMON\NWTOC-TEMPLATE.BAT C:\BAT\NWTOC.BAT /Y
    ECHO Local NWTOC.BAT updated
) ELSE (
    ECHO ERROR: T:\COMMON\NWTOC-TEMPLATE.BAT not found
    GOTO END
)

REM Also update the network copy (so it matches for future reference)
IF EXIST T:\%STATION%\NWTOC.BAT (
    COPY T:\COMMON\NWTOC-TEMPLATE.BAT T:\%STATION%\NWTOC.BAT /Y
    ECHO Network NWTOC.BAT updated
)

ECHO.
ECHO NWTOC.BAT update complete!
ECHO Station-specific sync removed
ECHO All updates now from T:\COMMON\ProdSW\
ECHO.

:END


Now convert this to DOS line endings and verify all files.


Bash

sed -i 's/$/\r/' /c/temp/DEPLOY-NWTOC-TODO.BAT && file /c/temp/*.BAT

Convert TODO template to DOS line endings and verify all files


/c/temp/DEPLOY-NWTOC-TODO.BAT: DOS batch file, ASCII text, with CRLF line terminators
/c/temp/NWTOC-TEMPLATE.BAT:    DOS batch file, ASCII text, with CRLF line terminators
/c/temp/UPDATE.BAT:            DOS batch file, ASCII text, with CRLF line terminators


Excellent! All three batch files have DOS line endings. Now I'll mark the current todo as complete and move on to deploying to AD2.


Perfect! All batch files verified with DOS line endings. Now let me update the todo list and deploy to AD2.


TodoWrite

Create simplified UPDATE.BAT with 3 commands (STATUS, UPDATE, DOS)

Create NWTOC-TEMPLATE.BAT without station-specific sync

Create TODO.BAT for NWTOC deployment

Verify DOS line endings (CR+LF) on all batch files

Deploy UPDATE.BAT to AD2 and sync to NAS

Test on TS-27 (STATUS, UPDATE, backward compat)


Now I need to deploy the files to AD2. Let me first check if I can reach AD2 and mount the share.


Now let me deploy the files to AD2:


Bash

Check if AD2 is still reachable


Reply from 192.168.0.6: bytes=32 time=68ms TTL=127
Reply from 192.168.0.6: bytes=32 time=82ms TTL=127


Good, AD2 is reachable. Now let me mount the share and deploy the files.


Write

$pass = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $pass)
New-PSDrive -Name "AD2Test" -PSProvider FileSystem -Root "\\192.168.0.6\test" -Credential $cred -ErrorAction Stop | Out-Null

Write-Host "=== Deploying Batch Files to AD2 ===" -ForegroundColor Cyan

# Backup existing UPDATE.BAT
if (Test-Path "AD2Test:\UPDATE.BAT") {
    $backupName = "UPDATE.BAT.backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    Write-Host "Backing up existing UPDATE.BAT to $backupName" -ForegroundColor Yellow
    Copy-Item "AD2Test:\UPDATE.BAT" "AD2Test:\$backupName"
}

# Deploy new UPDATE.BAT
Write-Host "Deploying new UPDATE.BAT..." -ForegroundColor Green
Copy-Item "C:\temp\UPDATE.BAT" "AD2Test:\UPDATE.BAT" -Force

# Deploy NWTOC-TEMPLATE.BAT to COMMON folder
Write-Host "Deploying NWTOC-TEMPLATE.BAT to COMMON..." -ForegroundColor Green
if (-not (Test-Path "AD2Test:\COMMON")) {
    Write-Host "  Creating COMMON folder..." -ForegroundColor Yellow
    New-Item -Path "AD2Test:\COMMON" -ItemType Directory | Out-Null
}
Copy-Item "C:\temp\NWTOC-TEMPLATE.BAT" "AD2Test:\COMMON\NWTOC-TEMPLATE.BAT" -Force

# Save DEPLOY-NWTOC-TODO.BAT as reference (don't deploy yet)
Write-Host "Saving DEPLOY-NWTOC-TODO.BAT as reference..." -ForegroundColor Green
Copy-Item "C:\temp\DEPLOY-NWTOC-TODO.BAT" "AD2Test:\COMMON\DEPLOY-NWTOC-TODO.BAT" -Force

# Verify deployments
Write-Host "`n=== Verification ===" -ForegroundColor Cyan
$files = @("UPDATE.BAT", "COMMON\NWTOC-TEMPLATE.BAT", "COMMON\DEPLOY-NWTOC-TODO.BAT")
foreach ($file in $files) {
    if (Test-Path "AD2Test:\$file") {
        $item = Get-Item "AD2Test:\$file"
        Write-Host "  ✓ $file ($($item.Length) bytes, modified $($item.LastWriteTime))" -ForegroundColor Green
    } else {
        Write-Host "  ✗ $file NOT FOUND" -ForegroundColor Red
    }
}

Write-Host "`n=== Deployment Complete ===" -ForegroundColor Green
Write-Host "Files will sync to NAS within 15 minutes (or run manual sync)" -ForegroundColor Yellow
Write-Host "`nNext steps:"
Write-Host "  1. Wait for sync or trigger manually"
Write-Host "  2. Test on TS-27: T:\UPDATE STATUS"
Write-Host "  3. Test on TS-27: T:\UPDATE UPDATE"

Remove-PSDrive -Name "AD2Test"


File created successfully at: C:\temp\deploy-to-ad2.ps1

$pass = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $pass)
New-PSDrive -Name "AD2Test" -PSProvider FileSystem -Root "\\192.168.0.6\test" -Credential $cred -ErrorAction Stop | Out-Null

Write-Host "=== Deploying Batch Files to AD2 ===" -ForegroundColor Cyan

# Backup existing UPDATE.BAT
if (Test-Path "AD2Test:\UPDATE.BAT") {
    $backupName = "UPDATE.BAT.backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    Write-Host "Backing up existing UPDATE.BAT to $backupName" -ForegroundColor Yellow
    Copy-Item "AD2Test:\UPDATE.BAT" "AD2Test:\$backupName"
}

# Deploy new UPDATE.BAT
Write-Host "Deploying new UPDATE.BAT..." -ForegroundColor Green
Copy-Item "C:\temp\UPDATE.BAT" "AD2Test:\UPDATE.BAT" -Force

# Deploy NWTOC-TEMPLATE.BAT to COMMON folder
Write-Host "Deploying NWTOC-TEMPLATE.BAT to COMMON..." -ForegroundColor Green
if (-not (Test-Path "AD2Test:\COMMON")) {
    Write-Host "  Creating COMMON folder..." -ForegroundColor Yellow
    New-Item -Path "AD2Test:\COMMON" -ItemType Directory | Out-Null
}
Copy-Item "C:\temp\NWTOC-TEMPLATE.BAT" "AD2Test:\COMMON\NWTOC-TEMPLATE.BAT" -Force

# Save DEPLOY-NWTOC-TODO.BAT as reference (don't deploy yet)
Write-Host "Saving DEPLOY-NWTOC-TODO.BAT as reference..." -ForegroundColor Green
Copy-Item "C:\temp\DEPLOY-NWTOC-TODO.BAT" "AD2Test:\COMMON\DEPLOY-NWTOC-TODO.BAT" -Force

# Verify deployments
Write-Host "`n=== Verification ===" -ForegroundColor Cyan
$files = @("UPDATE.BAT", "COMMON\NWTOC-TEMPLATE.BAT", "COMMON\DEPLOY-NWTOC-TODO.BAT")
foreach ($file in $files) {
    if (Test-Path "AD2Test:\$file") {
        $item = Get-Item "AD2Test:\$file"
        Write-Host "  ✓ $file ($($item.Length) bytes, modified $($item.LastWriteTime))" -ForegroundColor Green
    } else {
        Write-Host "  ✗ $file NOT FOUND" -ForegroundColor Red
    }
}

Write-Host "`n=== Deployment Complete ===" -ForegroundColor Green
Write-Host "Files will sync to NAS within 15 minutes (or run manual sync)" -ForegroundColor Yellow
Write-Host "`nNext steps:"
Write-Host "  1. Wait for sync or trigger manually"
Write-Host "  2. Test on TS-27: T:\UPDATE STATUS"
Write-Host "  3. Test on TS-27: T:\UPDATE UPDATE"

Remove-PSDrive -Name "AD2Test"


Bash

powershell.exe -ExecutionPolicy Bypass -File "C:\\temp\\deploy-to-ad2.ps1" 2>&1

Deploy batch files to AD2


Error: Exit code 1
At C:\temp\deploy-to-ad2.ps1:36 char:50
+         Write-Host "  �o" $file ($($item.Length) bytes, modified $($i ...
+                                                  ~~~~~
Unexpected token 'bytes' in expression or statement.
At C:\temp\deploy-to-ad2.ps1:36 char:49
+         Write-Host "  �o" $file ($($item.Length) bytes, modified $($i ...
+                                                 ~
Missing closing ')' in expression.
At C:\temp\deploy-to-ad2.ps1:34 char:37
+     if (Test-Path "AD2Test:\$file") {
+                                     ~
Missing closing '}' in statement block or type definition.
At C:\temp\deploy-to-ad2.ps1:33 char:27
+ foreach ($file in $files) {
+                           ~
Missing closing '}' in statement block or type definition.
At C:\temp\deploy-to-ad2.ps1:36 char:88
+ ... file ($($item.Length) bytes, modified $($item.LastWriteTime))" -Foreg ...
+                                                                 ~
Unexpected token ')' in expression or statement.
At C:\temp\deploy-to-ad2.ps1:38 char:23
+         Write-Host "  �o- $file NOT FOUND" -ForegroundColor Red
+                       ~~~
Unexpected token '�o-' in expression or statement.
At C:\temp\deploy-to-ad2.ps1:49 char:30
+ Remove-PSDrive -Name "AD2Test"
+                              ~
The string is missing the terminator: ".
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken


The deployment script had encoding issues with the checkmark and X symbols. Let me rewrite it without special characters.


Let me fix the PowerShell script with simpler output:


Write

$pass = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $pass)
New-PSDrive -Name "AD2Test" -PSProvider FileSystem -Root "\\192.168.0.6\test" -Credential $cred -ErrorAction Stop | Out-Null

Write-Host "=== Deploying Batch Files to AD2 ===" -ForegroundColor Cyan

# Backup existing UPDATE.BAT
if (Test-Path "AD2Test:\UPDATE.BAT") {
    $backupName = "UPDATE.BAT.backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    Write-Host "Backing up existing UPDATE.BAT to $backupName" -ForegroundColor Yellow
    Copy-Item "AD2Test:\UPDATE.BAT" "AD2Test:\$backupName"
}

# Deploy new UPDATE.BAT
Write-Host "Deploying new UPDATE.BAT..." -ForegroundColor Green
Copy-Item "C:\temp\UPDATE.BAT" "AD2Test:\UPDATE.BAT" -Force

# Deploy NWTOC-TEMPLATE.BAT to COMMON folder
Write-Host "Deploying NWTOC-TEMPLATE.BAT to COMMON..." -ForegroundColor Green
if (-not (Test-Path "AD2Test:\COMMON")) {
    Write-Host "  Creating COMMON folder..." -ForegroundColor Yellow
    New-Item -Path "AD2Test:\COMMON" -ItemType Directory | Out-Null
}
Copy-Item "C:\temp\NWTOC-TEMPLATE.BAT" "AD2Test:\COMMON\NWTOC-TEMPLATE.BAT" -Force

# Save DEPLOY-NWTOC-TODO.BAT as reference (don't deploy yet)
Write-Host "Deploying DEPLOY-NWTOC-TODO.BAT as reference..." -ForegroundColor Green
Copy-Item "C:\temp\DEPLOY-NWTOC-TODO.BAT" "AD2Test:\COMMON\DEPLOY-NWTOC-TODO.BAT" -Force

# Verify deployments
Write-Host ""
Write-Host "=== Verification ===" -ForegroundColor Cyan
$files = @("UPDATE.BAT", "COMMON\NWTOC-TEMPLATE.BAT", "COMMON\DEPLOY-NWTOC-TODO.BAT")
foreach ($file in $files) {
    if (Test-Path "AD2Test:\$file") {
        $item = Get-Item "AD2Test:\$file"
        Write-Host "  [OK] $file - $($item.Length) bytes, modified $($item.LastWriteTime)" -ForegroundColor Green
    } else {
        Write-Host "  [FAIL] $file NOT FOUND" -ForegroundColor Red
    }
}

Write-Host ""
Write-Host "=== Deployment Complete ===" -ForegroundColor Green
Write-Host "Files will sync to NAS within 15 minutes (or run manual sync)" -ForegroundColor Yellow
Write-Host ""
Write-Host "Next steps:"
Write-Host "  1. Wait for sync or trigger manually"
Write-Host "  2. Test on TS-27: T:\UPDATE STATUS"
Write-Host "  3. Test on TS-27: T:\UPDATE UPDATE"

Remove-PSDrive -Name "AD2Test"


The file C:\temp\deploy-to-ad2.ps1 has been updated. Here's the result of running `cat -n` on a snippet of the edited file:
     1→$pass = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
     2→$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $pass)
     3→New-PSDrive -Name "AD2Test" -PSProvider FileSystem -Root "\\192.168.0.6\test" -Credential $cred -ErrorAction Stop | Out-Null
     4→
     5→Write-Host "=== Deploying Batch Files to AD2 ===" -ForegroundColor Cyan
     6→
     7→# Backup existing UPDATE.BAT
     8→if (Test-Path "AD2Test:\UPDATE.BAT") {
     9→    $backupName = "UPDATE.BAT.backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    10→    Write-Host "Backing up existing UPDATE.BAT to $backupName" -ForegroundColor Yellow
    11→    Copy-Item "AD2Test:\UPDATE.BAT" "AD2Test:\$backupName"
    12→}
    13→
    14→# Deploy new UPDATE.BAT
    15→Write-Host "Deploying new UPDATE.BAT..." -ForegroundColor Green
    16→Copy-Item "C:\temp\UPDATE.BAT" "AD2Test:\UPDATE.BAT" -Force
    17→
    18→# Deploy NWTOC-TEMPLATE.BAT to COMMON folder
    19→Write-Host "Deploying NWTOC-TEMPLATE.BAT to COMMON..." -ForegroundColor Green
    20→if (-not (Test-Path "AD2Test:\COMMON")) {
    21→    Write-Host "  Creating COMMON folder..." -ForegroundColor Yellow
    22→    New-Item -Path "AD2Test:\COMMON" -ItemType Directory | Out-Null
    23→}
    24→Copy-Item "C:\temp\NWTOC-TEMPLATE.BAT" "AD2Test:\COMMON\NWTOC-TEMPLATE.BAT" -Force
    25→
    26→# Save DEPLOY-NWTOC-TODO.BAT as reference (don't deploy yet)
    27→Write-Host "Deploying DEPLOY-NWTOC-TODO.BAT as reference..." -ForegroundColor Green
    28→Copy-Item "C:\temp\DEPLOY-NWTOC-TODO.BAT" "AD2Test:\COMMON\DEPLOY-NWTOC-TODO.BAT" -Force
    29→
    30→# Verify deployments
    31→Write-Host ""
    32→Write-Host "=== Verification ===" -ForegroundColor Cyan
    33→$files = @("UPDATE.BAT", "COMMON\NWTOC-TEMPLATE.BAT", "COMMON\DEPLOY-NWTOC-TODO.BAT")
    34→foreach ($file in $files) {
    35→    if (Test-Path "AD2Test:\$file") {
    36→        $item = Get-Item "AD2Test:\$file"
    37→        Write-Host "  [OK] $file - $($item.Length) bytes, modified $($item.LastWriteTime)" -ForegroundColor Green
    38→    } else {
    39→        Write-Host "  [FAIL] $file NOT FOUND" -ForegroundColor Red
    40→    }
    41→}
    42→
    43→Write-Host ""
    44→Write-Host "=== Deployment Complete ===" -ForegroundColor Green
    45→Write-Host "Files will sync to NAS within 15 minutes (or run manual sync)" -ForegroundColor Yellow
    46→Write-Host ""
    47→Write-Host "Next steps:"
    48→Write-Host "  1. Wait for sync or trigger manually"
    49→Write-Host "  2. Test on TS-27: T:\UPDATE STATUS"
    50→Write-Host "  3. Test on TS-27: T:\UPDATE UPDATE"
    51→
    52→Remove-PSDrive -Name "AD2Test"
    53→

$pass = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $pass)
New-PSDrive -Name "AD2Test" -PSProvider FileSystem -Root "\\192.168.0.6\test" -Credential $cred -ErrorAction Stop | Out-Null

Write-Host "=== Deploying Batch Files to AD2 ===" -ForegroundColor Cyan

# Backup existing UPDATE.BAT
if (Test-Path "AD2Test:\UPDATE.BAT") {
    $backupName = "UPDATE.BAT.backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    Write-Host "Backing up existing UPDATE.BAT to $backupName" -ForegroundColor Yellow
    Copy-Item "AD2Test:\UPDATE.BAT" "AD2Test:\$backupName"
}

# Deploy new UPDATE.BAT
Write-Host "Deploying new UPDATE.BAT..." -ForegroundColor Green
Copy-Item "C:\temp\UPDATE.BAT" "AD2Test:\UPDATE.BAT" -Force

# Deploy NWTOC-TEMPLATE.BAT to COMMON folder
Write-Host "Deploying NWTOC-TEMPLATE.BAT to COMMON..." -ForegroundColor Green
if (-not (Test-Path "AD2Test:\COMMON")) {
    Write-Host "  Creating COMMON folder..." -ForegroundColor Yellow
    New-Item -Path "AD2Test:\COMMON" -ItemType Directory | Out-Null
}
Copy-Item "C:\temp\NWTOC-TEMPLATE.BAT" "AD2Test:\COMMON\NWTOC-TEMPLATE.BAT" -Force

# Save DEPLOY-NWTOC-TODO.BAT as reference (don't deploy yet)
Write-Host "Deploying DEPLOY-NWTOC-TODO.BAT as reference..." -ForegroundColor Green
Copy-Item "C:\temp\DEPLOY-NWTOC-TODO.BAT" "AD2Test:\COMMON\DEPLOY-NWTOC-TODO.BAT" -Force

# Verify deployments
Write-Host ""
Write-Host "=== Verification ===" -ForegroundColor Cyan
$files = @("UPDATE.BAT", "COMMON\NWTOC-TEMPLATE.BAT", "COMMON\DEPLOY-NWTOC-TODO.BAT")
foreach ($file in $files) {
    if (Test-Path "AD2Test:\$file") {
        $item = Get-Item "AD2Test:\$file"
        Write-Host "  [OK] $file - $($item.Length) bytes, modified $($item.LastWriteTime)" -ForegroundColor Green
    } else {
        Write-Host "  [FAIL] $file NOT FOUND" -ForegroundColor Red
    }
}

Write-Host ""
Write-Host "=== Deployment Complete ===" -ForegroundColor Green
Write-Host "Files will sync to NAS within 15 minutes (or run manual sync)" -ForegroundColor Yellow
Write-Host ""
Write-Host "Next steps:"
Write-Host "  1. Wait for sync or trigger manually"
Write-Host "  2. Test on TS-27: T:\UPDATE STATUS"
Write-Host "  3. Test on TS-27: T:\UPDATE UPDATE"

Remove-PSDrive -Name "AD2Test"

-Write-Host "Saving DEPLOY-NWTOC-TODO.BAT as reference..." -ForegroundColor Green

+Write-Host "Deploying DEPLOY-NWTOC-TODO.BAT as reference..." -ForegroundColor Green

-Write-Host "`n=== Verification ===" -ForegroundColor Cyan

+Write-Host "=== Verification ===" -ForegroundColor Cyan

-        Write-Host "  ✓ $file ($($item.Length) bytes, modified $($item.LastWriteTime))" -ForegroundColor Green

+        Write-Host "  [OK] $file - $($item.Length) bytes, modified $($item.LastWriteTime)" -ForegroundColor Green

-        Write-Host "  ✗ $file NOT FOUND" -ForegroundColor Red

+        Write-Host "  [FAIL] $file NOT FOUND" -ForegroundColor Red

-Write-Host "`n=== Deployment Complete ===" -ForegroundColor Green

+Write-Host "=== Deployment Complete ===" -ForegroundColor Green

$pass = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $pass)
New-PSDrive -Name "AD2Test" -PSProvider FileSystem -Root "\\192.168.0.6\test" -Credential $cred -ErrorAction Stop | Out-Null

Write-Host "=== Deploying Batch Files to AD2 ===" -ForegroundColor Cyan

# Backup existing UPDATE.BAT
if (Test-Path "AD2Test:\UPDATE.BAT") {
    $backupName = "UPDATE.BAT.backup-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
    Write-Host "Backing up existing UPDATE.BAT to $backupName" -ForegroundColor Yellow
    Copy-Item "AD2Test:\UPDATE.BAT" "AD2Test:\$backupName"
}

# Deploy new UPDATE.BAT
Write-Host "Deploying new UPDATE.BAT..." -ForegroundColor Green
Copy-Item "C:\temp\UPDATE.BAT" "AD2Test:\UPDATE.BAT" -Force

# Deploy NWTOC-TEMPLATE.BAT to COMMON folder
Write-Host "Deploying NWTOC-TEMPLATE.BAT to COMMON..." -ForegroundColor Green
if (-not (Test-Path "AD2Test:\COMMON")) {
    Write-Host "  Creating COMMON folder..." -ForegroundColor Yellow
    New-Item -Path "AD2Test:\COMMON" -ItemType Directory | Out-Null
}
Copy-Item "C:\temp\NWTOC-TEMPLATE.BAT" "AD2Test:\COMMON\NWTOC-TEMPLATE.BAT" -Force

# Save DEPLOY-NWTOC-TODO.BAT as reference (don't deploy yet)
Write-Host "Saving DEPLOY-NWTOC-TODO.BAT as reference..." -ForegroundColor Green
Copy-Item "C:\temp\DEPLOY-NWTOC-TODO.BAT" "AD2Test:\COMMON\DEPLOY-NWTOC-TODO.BAT" -Force

# Verify deployments
Write-Host "`n=== Verification ===" -ForegroundColor Cyan
$files = @("UPDATE.BAT", "COMMON\NWTOC-TEMPLATE.BAT", "COMMON\DEPLOY-NWTOC-TODO.BAT")
foreach ($file in $files) {
    if (Test-Path "AD2Test:\$file") {
        $item = Get-Item "AD2Test:\$file"
        Write-Host "  ✓ $file ($($item.Length) bytes, modified $($item.LastWriteTime))" -ForegroundColor Green
    } else {
        Write-Host "  ✗ $file NOT FOUND" -ForegroundColor Red
    }
}

Write-Host "`n=== Deployment Complete ===" -ForegroundColor Green
Write-Host "Files will sync to NAS within 15 minutes (or run manual sync)" -ForegroundColor Yellow
Write-Host "`nNext steps:"
Write-Host "  1. Wait for sync or trigger manually"
Write-Host "  2. Test on TS-27: T:\UPDATE STATUS"
Write-Host "  3. Test on TS-27: T:\UPDATE UPDATE"

Remove-PSDrive -Name "AD2Test"


Good, the script is fixed. Now let me run it again.


Bash

powershell.exe -ExecutionPolicy Bypass -File "C:\\temp\\deploy-to-ad2.ps1" 2>&1

Deploy batch files to AD2 (fixed script)


=== Deploying Batch Files to AD2 ===
Backing up existing UPDATE.BAT to UPDATE.BAT.backup-20260115-143933
Deploying new UPDATE.BAT...
Deploying NWTOC-TEMPLATE.BAT to COMMON...
  Creating COMMON folder...
Deploying DEPLOY-NWTOC-TODO.BAT as reference...

=== Verification ===
  [OK] UPDATE.BAT - 9845 bytes, modified 01/15/2026 12:42:03
  [OK] COMMON\NWTOC-TEMPLATE.BAT - 2463 bytes, modified 01/15/2026 12:42:41
  [OK] COMMON\DEPLOY-NWTOC-TODO.BAT - 1581 bytes, modified 01/15/2026 14:38:21

=== Deployment Complete ===
Files will sync to NAS within 15 minutes (or run manual sync)

Next steps:
  1. Wait for sync or trigger manually
  2. Test on TS-27: T:\UPDATE STATUS
  3. Test on TS-27: T:\UPDATE UPDATE


Excellent! All files deployed successfully to AD2. Now let me check if they've been synced to the NAS, and then update the todo list to mark deployment as complete.


Perfect! Files deployed to AD2. Let me check if they've synced to the NAS yet:


"C:/Program Files/PuTTY/plink.exe" -ssh root@192.168.0.9 -pw "Paper123!@#-nas" -hostkey "SHA256:5CVIPlqjLPxO8n48PKLAP99nE6XkEBAjTkaYmJAeOdA" -batch "ls -lh /data/test/UPDATE.BAT /data/test/COMMON/NWTOC-TEMPLATE.BAT 2>&1" 2>&1

Check if files synced to NAS


Error: Exit code 2
ls: cannot access '/data/test/COMMON/NWTOC-TEMPLATE.BAT': No such file or directory
-rwxrwxrwx+ 1 root root 5.1K Dec 16 09:20 /data/test/UPDATE.BAT


The new UPDATE.BAT hasn't synced yet (still showing the old one from Dec 16). The COMMON folder also doesn't exist on the NAS yet. This is expected - the sync runs every 15 minutes. I should mark the deployment as complete since the files are on AD2, and the sync will happen automatically.

Let me update the documentation and mark this todo as complete. Then I'll create a summary document for the user about what was completed and what the next steps are for testing.


Files are on AD2 and will sync to NAS automatically within 15 minutes. Let me update the todo list and create a summary document:


TodoWrite

Create simplified UPDATE.BAT with 3 commands (STATUS, UPDATE, DOS)

Create NWTOC-TEMPLATE.BAT without station-specific sync

Create TODO.BAT for NWTOC deployment

Verify DOS line endings (CR+LF) on all batch files

Deploy UPDATE.BAT to AD2 and sync to NAS

Test on TS-27 (STATUS, UPDATE, backward compat)


Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable

Create simplified UPDATE.BAT with 3 commands (STATUS, UPDATE, DOS)

Create NWTOC-TEMPLATE.BAT without station-specific sync

Create TODO.BAT for NWTOC deployment

Verify DOS line endings (CR+LF) on all batch files

Deploy UPDATE.BAT to AD2 and sync to NAS

Test on TS-27 (STATUS, UPDATE, backward compat)

Create TODO.BAT for NWTOC deployment


Now let me create a comprehensive summary document for the user explaining what was done, what's ready for testing, and the next steps.


Now let me create a summary document:


Write

# UPDATE.BAT v2.0 - Simplified DOS Update Utility

**Date:** 2026-01-15
**Status:** ✅ Implementation Complete - Ready for Testing

---

## Summary of Changes

Successfully simplified the DOS update utility for Dataforth test machines:

### ✅ Completed

1. **Reduced Commands** - From 5 to 3 commands (60% reduction):
   - **STATUS** (replaces CHECK) - Quick diagnostic
   - **UPDATE** (replaces ALL) - One-stop update: backup + scripts
   - **DOS** (unchanged) - System update requiring reboot

2. **Removed Station-Specific Sync** - Eliminated `T:\TS-XX\ProdSW\` complexity:
   - All machines now receive identical updates from `T:\COMMON\ProdSW\`
   - Single source of truth for batch files
   - No more per-station customization

3. **Added Auto-Detection** - Station name can now be auto-detected:
   - `T:\UPDATE STATUS` (auto-detect from SYSTEM.INI)
   - `T:\UPDATE TS-27 STATUS` (explicit - backward compatible)

4. **Maintained Backward Compatibility**:
   - Old commands still work (mapped to new commands)
   - `CHECK` → `STATUS`
   - `BACKUP`, `SCRIPTS`, `ALL` → `UPDATE`

---

## Files Created & Deployed

### On AD2 (\\AD2\test\)

| File | Size | Purpose | Status |
|------|------|---------|--------|
| **UPDATE.BAT** | 9,845 bytes | Main simplified update utility | ✅ Deployed |
| **COMMON\NWTOC-TEMPLATE.BAT** | 2,463 bytes | Boot script template (no station-specific sync) | ✅ Deployed |
| **COMMON\DEPLOY-NWTOC-TODO.BAT** | 1,581 bytes | Deployment script for updating NWTOC.BAT on all stations | ✅ Deployed |

**Backup Created:** `UPDATE.BAT.backup-20260115-143933` (old version saved)

### Sync Status
- ✅ Files deployed to AD2 at 14:39 (2026-01-15)
- ⏳ **Syncing to NAS** - Automatic sync runs every 15 minutes
- ⏳ **Will be available to DOS machines** after sync completes

---

## What Changed in UPDATE.BAT

### Before (v1.0 - Complex)
```batch
T:\UPDATE TS-27 CHECK      # Show DOS version, list dirs
T:\UPDATE TS-27 BACKUP     # Backup to network
T:\UPDATE TS-27 SCRIPTS    # Update from COMMON + TS-XX/ProdSW
T:\UPDATE TS-27 DOS        # Update DOS system files
T:\UPDATE TS-27 ALL        # CHECK + BACKUP + SCRIPTS (confusing - doesn't include DOS)
```

**Issues:**
- 5 commands to remember
- Station-specific sync adds complexity
- ALL command doesn't do "all" (missing DOS)
- Too many steps for simple workflow

### After (v2.0 - Simplified)
```batch
# New simple commands:
T:\UPDATE STATUS           # Quick diagnostic (auto-detect station)
T:\UPDATE UPDATE           # Backup + update scripts (auto-detect station)
T:\UPDATE DOS              # System update (auto-detect station)

# Old commands still work (backward compatible):
T:\UPDATE TS-27 CHECK      # Maps to STATUS
T:\UPDATE TS-27 BACKUP     # Maps to UPDATE
T:\UPDATE TS-27 SCRIPTS    # Maps to UPDATE
T:\UPDATE TS-27 ALL        # Maps to UPDATE
```

**Improvements:**
- 60% fewer commands (5→3)
- Single workflow: `T:\UPDATE UPDATE` does everything
- Auto-detection reduces typing errors
- No more station-specific sync complexity
- Clear command names

---

## What Changed in NWTOC.BAT

### Before (Complex)
```batch
# Update common batch files
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\

# Update station-specific files (REMOVED)
IF EXIST T:\TS-XX\ProdSW\*.EXE COPY T:\TS-XX\ProdSW\*.EXE C:\ATE\
IF EXIST T:\TS-XX\ProdSW\*.BAT COPY T:\TS-XX\ProdSW\*.BAT C:\BAT\
```

### After (Simplified)
```batch
# Update common batch files ONLY
IF EXIST T:\COMMON\ProdSW\*.BAT COPY T:\COMMON\ProdSW\*.BAT C:\BAT\ /Y

# Station-specific sync removed per 2026-01-15 simplification
# All machines now use identical COMMON updates
```

---

## Testing Plan

### Phase 1: Test UPDATE.BAT on TS-27

**Prerequisites:**
- VPN connected to Dataforth network
- UPDATE.BAT synced to NAS (check: `T:\UPDATE.BAT` should be 9,845 bytes)

**Test Commands:**

1. **Test STATUS command (new)**
   ```batch
   T:\UPDATE STATUS
   ```
   **Expected:** Shows DOS version, disk space, network check, directory listing

2. **Test STATUS with explicit station (backward compat)**
   ```batch
   T:\UPDATE TS-27 STATUS
   ```
   **Expected:** Same output as above

3. **Test old CHECK command (backward compat)**
   ```batch
   T:\UPDATE TS-27 CHECK
   ```
   **Expected:** Maps to STATUS, same output

4. **Test UPDATE command (new - does everything)**
   ```batch
   T:\UPDATE UPDATE
   ```
   **Expected:**
   - Progress indicators: [1/3] Status, [2/3] Backup, [3/3] Scripts
   - Backup created in `T:\TS-27\Backup\`
   - Scripts updated from `T:\COMMON\ProdSW\` ONLY
   - No errors about missing station-specific folders

5. **Test old ALL command (backward compat)**
   ```batch
   T:\UPDATE TS-27 ALL
   ```
   **Expected:** Maps to UPDATE, same as test #4

6. **Test old BACKUP command (backward compat)**
   ```batch
   T:\UPDATE TS-27 BACKUP
   ```
   **Expected:** Maps to UPDATE, runs full update

7. **Test old SCRIPTS command (backward compat)**
   ```batch
   T:\UPDATE TS-27 SCRIPTS
   ```
   **Expected:** Maps to UPDATE, runs full update

8. **Test invalid command (error handling)**
   ```batch
   T:\UPDATE INVALID
   ```
   **Expected:** Shows usage message

### Phase 2: Deploy NWTOC.BAT Updates (After UPDATE.BAT Validated)

**Method:** Use TODO.BAT mechanism

1. **Test on single station first (TS-27)**
   ```batch
   # On AD2, copy TODO.BAT to TS-27 folder:
   Copy-Item "C:\Shares\test\COMMON\DEPLOY-NWTOC-TODO.BAT" "C:\Shares\test\TS-27\TODO.BAT"
   ```

2. **Wait for sync** (15 min) or trigger manually

3. **Reboot TS-27** - TODO.BAT will execute and update NWTOC.BAT

4. **Verify on TS-27**
   ```batch
   TYPE C:\BAT\NWTOC.BAT
   ```
   Should show "Station-specific sync removed" comment

5. **Deploy to remaining stations** (after TS-27 validates)
   ```powershell
   # On AD2, deploy to all active stations:
   1..30 | ForEach-Object {
       $station = "TS-$_"
       Copy-Item "C:\Shares\test\COMMON\DEPLOY-NWTOC-TODO.BAT" "C:\Shares\test\$station\TODO.BAT" -ErrorAction SilentlyContinue
   }
   ```

---

## Success Criteria

- [x] UPDATE.BAT v2.0 created with 3 commands
- [x] Station-specific sync removed from UPDATE.BAT
- [x] NWTOC-TEMPLATE.BAT created without station-specific sync
- [x] All files have DOS line endings (CR+LF)
- [x] Files deployed to AD2
- [ ] **Files synced to NAS** (automatic, within 15 min)
- [ ] **UPDATE STATUS works on TS-27**
- [ ] **UPDATE UPDATE works on TS-27**
- [ ] **Backward compatibility verified** (old commands work)
- [ ] **NWTOC.BAT updated on TS-27** (via TODO.BAT)
- [ ] **No station-specific folders accessed** (verified in logs)

---

## Next Steps

### Immediate (You Need to Do)

1. **Wait 15 minutes** for sync to complete, then verify UPDATE.BAT on NAS:
   ```bash
   ssh root@192.168.0.9
   ls -lh /data/test/UPDATE.BAT
   # Should show: 9845 bytes, dated today
   ```

2. **Test on TS-27** (VPN required):
   - Run STATUS command: `T:\UPDATE STATUS`
   - Run UPDATE command: `T:\UPDATE UPDATE`
   - Verify backward compat: `T:\UPDATE TS-27 CHECK`

3. **Verify backup created**:
   - Check `T:\TS-27\Backup\` has ATE and BAT folders
   - Check timestamps match test run

4. **Deploy NWTOC update to TS-27**:
   - Place TODO.BAT in `\\AD2\test\TS-27\`
   - Reboot TS-27
   - Verify new NWTOC.BAT (no station-specific sync)

### After TS-27 Validation

5. **Deploy to remaining stations** (staggered deployment):
   - Week 1: 5 more stations
   - Week 2: Remaining stations (if no issues)

6. **Update documentation**:
   - Engineer handbook
   - Email Engineering team with command translation table

7. **Monitor for 1 week**:
   - Check sync logs
   - Verify no errors about missing ProdSW folders
   - Confirm all machines using COMMON updates

---

## Rollback Plan

If issues arise:

### Rollback UPDATE.BAT
```powershell
# On AD2:
Copy-Item "C:\Shares\test\UPDATE.BAT.backup-20260115-143933" "C:\Shares\test\UPDATE.BAT" -Force
```

### Rollback NWTOC.BAT (Per Station)
```batch
# Create TODO.BAT with old NWTOC.BAT code
# Deploy via sync system
```

---

## Files for Reference

**Local (C:\temp\):**
- `UPDATE.BAT` - New simplified version
- `NWTOC-TEMPLATE.BAT` - New boot script template
- `DEPLOY-NWTOC-TODO.BAT` - Deployment script

**AD2 (\\AD2\test\):**
- `UPDATE.BAT` - Deployed and active
- `UPDATE.BAT.backup-20260115-143933` - Old version (for rollback)
- `COMMON\NWTOC-TEMPLATE.BAT` - Template for boot script updates
- `COMMON\DEPLOY-NWTOC-TODO.BAT` - Deployment script

**NAS (/data/test/):**
- `UPDATE.BAT` - Will sync from AD2 (automatic)
- `COMMON/NWTOC-TEMPLATE.BAT` - Will sync from AD2 (automatic)

---

## Command Translation Table (for Engineers)

| Old Command | New Command | Notes |
|-------------|-------------|-------|
| `UPDATE TS-XX CHECK` | `UPDATE STATUS` | Auto-detect station, or explicit: `UPDATE TS-XX STATUS` |
| `UPDATE TS-XX BACKUP` | `UPDATE UPDATE` | Now includes backup + scripts |
| `UPDATE TS-XX SCRIPTS` | `UPDATE UPDATE` | Now includes backup + scripts |
| `UPDATE TS-XX ALL` | `UPDATE UPDATE` | Renamed for clarity |
| `UPDATE TS-XX DOS` | `UPDATE DOS` | Unchanged (can auto-detect) |

**All old commands still work** (backward compatible mapping).

---

## Benefits Summary

1. **Simpler Workflow**
   - One command to rule them all: `UPDATE UPDATE`
   - No need to remember CHECK → BACKUP → SCRIPTS sequence

2. **Reduced Complexity**
   - No more station-specific ProdSW folders
   - Single source of truth: T:\COMMON\ProdSW\
   - Easier to maintain and troubleshoot

3. **Better UX**
   - Auto-detection reduces typing errors
   - Clear command names (STATUS vs CHECK)
   - Progress indicators during UPDATE
   - Better error messages

4. **Maintained Compatibility**
   - Old syntax still works (no retraining needed)
   - Gradual migration path
   - Easy rollback if issues arise

---

## Questions or Issues?

If you encounter any problems:
1. Check sync status: `\\AD2\test\_SYNC_STATUS.txt`
2. Check sync log: `\\AD2\test\scripts\sync-from-nas.log`
3. Check NAS directly: `ssh root@192.168.0.9` → `ls -lh /data/test/UPDATE.BAT`
4. Rollback if needed (see Rollback Plan above)

---

**Implementation Complete!** 🎉

Ready for testing on TS-27 when you're back on VPN.