@ECHO OFF
REM One-time deployment script for DOS Update System
REM Usage: T:\COMMON\ProdSW\DEPLOY.BAT machine-name
REM Version: 4.1 - Fixed trailing space bug in ECHO >> redirects
REM Last modified: 2026-03-12

CLS

REM Check machine name parameter
IF "%1"=="" GOTO NO_MACHINE

REM Save machine name
SET MACHINE=%1

ECHO ==============================================================
ECHO DOS Update System - Deployment v4.1
ECHO ==============================================================
ECHO Machine: %MACHINE%
ECHO ==============================================================
ECHO.
ECHO Press any key to install...
PAUSE >NUL
ECHO.

REM Create local directories
MD C:\BAT >NUL
MD C:\BATCH >NUL
MD C:\TEMP >NUL
MD C:\ATE >NUL
MD C:\NET >NUL

ECHO (1/3) Copying batch files to C:\BAT...
COPY T:\COMMON\ProdSW\*.BAT C:\BAT >NUL
ECHO      Batch files installed
ECHO.

ECHO (2/3) Creating machine directory on network...
MD T:\%MACHINE% >NUL
MD T:\%MACHINE%\LOGS >NUL
MD T:\%MACHINE%\LOGS\5BLOG >NUL
MD T:\%MACHINE%\LOGS\7BLOG >NUL
MD T:\%MACHINE%\LOGS\8BLOG >NUL
MD T:\%MACHINE%\LOGS\DSCLOG >NUL
MD T:\%MACHINE%\LOGS\HVLOG >NUL
MD T:\%MACHINE%\LOGS\PWRLOG >NUL
MD T:\%MACHINE%\LOGS\SCTLOG >NUL
MD T:\%MACHINE%\LOGS\VASLOG >NUL
MD T:\%MACHINE%\Reports >NUL
MD T:\%MACHINE%\BACKUP >NUL
ECHO      Network directories created
ECHO.

ECHO (3/3) Installing AUTOEXEC.BAT...
REM Create AUTOEXEC.BAT with machine name - no IF EXIST checks
REM NOTE: Redirect BEFORE echo to avoid trailing spaces in output
REM First line uses > to overwrite, rest use >> to append
>C:\AUTOEXEC.BAT ECHO @ECHO OFF
>>C:\AUTOEXEC.BAT ECHO REM Dataforth Test Machine Startup - DOS 6.22
>>C:\AUTOEXEC.BAT ECHO REM Version: 4.1 - No IF EXIST checks
>>C:\AUTOEXEC.BAT ECHO REM Deployed: 2026-03-12
>>C:\AUTOEXEC.BAT ECHO.
>>C:\AUTOEXEC.BAT ECHO SET MACHINE=%MACHINE%
>>C:\AUTOEXEC.BAT ECHO SET PATH=C:\DOS;C:\NET;C:\BAT;C:\BATCH;C:\
>>C:\AUTOEXEC.BAT ECHO PROMPT $P$G
>>C:\AUTOEXEC.BAT ECHO SET TEMP=C:\TEMP
>>C:\AUTOEXEC.BAT ECHO SET TMP=C:\TEMP
>>C:\AUTOEXEC.BAT ECHO.
>>C:\AUTOEXEC.BAT ECHO CLS
>>C:\AUTOEXEC.BAT ECHO ECHO.
>>C:\AUTOEXEC.BAT ECHO ECHO ==============================================================
>>C:\AUTOEXEC.BAT ECHO ECHO   Dataforth Test Machine: %MACHINE%
>>C:\AUTOEXEC.BAT ECHO ECHO   AUTOEXEC v4.1 - 2026-03-12
>>C:\AUTOEXEC.BAT ECHO ECHO ==============================================================
>>C:\AUTOEXEC.BAT ECHO ECHO.
>>C:\AUTOEXEC.BAT ECHO.
>>C:\AUTOEXEC.BAT ECHO MD C:\TEMP >NUL
>>C:\AUTOEXEC.BAT ECHO MD C:\BAT >NUL
>>C:\AUTOEXEC.BAT ECHO MD C:\BATCH >NUL
>>C:\AUTOEXEC.BAT ECHO.
>>C:\AUTOEXEC.BAT ECHO ECHO Starting network client...
>>C:\AUTOEXEC.BAT ECHO ECHO.
>>C:\AUTOEXEC.BAT ECHO CALL C:\STARTNET.BAT
>>C:\AUTOEXEC.BAT ECHO.
>>C:\AUTOEXEC.BAT ECHO ECHO.
>>C:\AUTOEXEC.BAT ECHO ECHO Network Drives:
>>C:\AUTOEXEC.BAT ECHO ECHO   T: = \\D2TESTNAS\test
>>C:\AUTOEXEC.BAT ECHO ECHO   X: = \\D2TESTNAS\datasheets
>>C:\AUTOEXEC.BAT ECHO ECHO.
>>C:\AUTOEXEC.BAT ECHO.
>>C:\AUTOEXEC.BAT ECHO ECHO Checking for software updates...
>>C:\AUTOEXEC.BAT ECHO CALL C:\BAT\NWTOC.BAT
>>C:\AUTOEXEC.BAT ECHO.
>>C:\AUTOEXEC.BAT ECHO ECHO Uploading test data to network...
>>C:\AUTOEXEC.BAT ECHO CALL C:\BAT\CTONW.BAT
>>C:\AUTOEXEC.BAT ECHO.
>>C:\AUTOEXEC.BAT ECHO ECHO.
>>C:\AUTOEXEC.BAT ECHO ECHO ==============================================================
>>C:\AUTOEXEC.BAT ECHO ECHO System Ready
>>C:\AUTOEXEC.BAT ECHO ECHO ==============================================================
>>C:\AUTOEXEC.BAT ECHO ECHO.
>>C:\AUTOEXEC.BAT ECHO CD \ATE
>>C:\AUTOEXEC.BAT ECHO menux
ECHO      AUTOEXEC.BAT installed with MACHINE=%MACHINE%
ECHO.

ECHO ==============================================================
ECHO Deployment Complete v4.1 - REBOOT NOW
ECHO ==============================================================
ECHO.
PAUSE
GOTO END

:NO_MACHINE
ECHO.
ECHO ERROR: Machine name not provided
ECHO.
ECHO Usage: DEPLOY.BAT machine-name
ECHO Example: DEPLOY.BAT TS-4R
ECHO.
PAUSE
GOTO END

:END
SET MACHINE=
