@ECHO OFF
REM STARTNET.BAT - Start Microsoft Network Client and map drives
REM Called from AUTOEXEC.BAT
REM
REM Version: 2.0
REM Last modified: 2026-01-19

REM ==================================================================
REM STEP 1: Start network client
REM ==================================================================

REM Load network protocols and drivers
REM This starts the Microsoft Network Client that was loaded via CONFIG.SYS
NET START

REM Check if NET START succeeded
IF ERRORLEVEL 1 GOTO NET_START_FAILED

ECHO (OK) Network client started

REM ==================================================================
REM STEP 2: Map network drives
REM ==================================================================

REM Map T: to test share (SMB1 compatible)
REM /YES = Don't prompt for confirmation
NET USE T: \\D2TESTNAS\test /YES
IF ERRORLEVEL 1 GOTO T_DRIVE_FAILED

ECHO (OK) T: mapped to \\D2TESTNAS\test

REM Map X: to datasheets share
NET USE X: \\D2TESTNAS\datasheets /YES
IF ERRORLEVEL 1 GOTO X_DRIVE_FAILED

ECHO (OK) X: mapped to \\D2TESTNAS\datasheets

GOTO END

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

:NET_START_FAILED
ECHO ERROR: Network client failed to start
ECHO.
ECHO Check:
ECHO - Network cable is connected
ECHO - CONFIG.SYS has correct network drivers
ECHO - PROTOCOL.INI is configured correctly
ECHO.
GOTO END

:T_DRIVE_FAILED
ECHO ERROR: Failed to map T: drive
ECHO.
ECHO Check:
ECHO - Server \\D2TESTNAS is online
ECHO - Share \\D2TESTNAS\test exists
ECHO - Network connectivity to 172.16.3.0/24 network
ECHO - SMB1 protocol enabled on NAS
ECHO.
GOTO END

:X_DRIVE_FAILED
ECHO ERROR: Failed to map X: drive
ECHO.
ECHO Check:
ECHO - Server \\D2TESTNAS is online
ECHO - Share \\D2TESTNAS\datasheets exists
ECHO.
GOTO END

:END
REM Return to AUTOEXEC.BAT
