@echo OFF

REM Copyright (C) 1994-1995 Microsoft Corporation
REM
REM This batch file is the Systems Management Server (SMS) logon script
REM for workstations logging in to a Windows NT or LAN Manager server.
REM It installs the SMS client components and collects hardware and
REM software inventory data.

echo.
echo Microsoft Systems Management Server (SMS)
echo.

REM If the SMSLS environment variable is set on the workstation (e.g.,
REM set SMSLS=1), verbose output will be enabled for SETLS16, CLI_DOS,
REM and INVDOS or SETLS32, CLI_NT and INVWIN32.

if "%SMSLS%" == "" goto START
set SMS_VERBOSE=/v
echo Executing SMS logon script.
goto START

REM Determine the binary files directory on the SMS logon server by
REM checking environment variables for operating system and processor
REM architecture. Set environment variables for this directory and
REM for the OS type. The directory this file exists in and the platform
REM specific directory beneath it are added to the path so that the proper
REM version of SETLS and NLSMSG can be called.

:START

REM Check to see if we can save path and reserve the neccessary environment
REM space before continuing.
set SMS_P=%PATH%

set SMS_TEMP=123456789012345678901234567890123456789012345
if "%SMS_TEMP%"=="123456789012345678901234567890123456789012345" goto FIND_OS
goto LOW_ENV

:FIND_OS
set SMS_TEMP=

if "%OS%" == "Windows_NT" goto NT_BIN

REM Determine the DOS version and exit if OS/2 1.3 or greater.
%0\..\dosver
if errorlevel 13 goto OS2


:DOS_BIN
set SMS_OS=16
set SMS_BIN=x86.bin
goto RUN_FROM

:NT_BIN
if "%PROCESSOR_ARCHITECTURE%" == "ALPHA" goto NT_ALPHA
if "%PROCESSOR_ARCHITECTURE%" == "MIPS"  goto NT_MIPS
if "%PROCESSOR_ARCHITECTURE%" == "x86"   goto NT_X86


echo.
echo Unable to determine operating system or processor architecture.
echo.
echo Consult your network administrator.
echo.
pause
goto END


:NT_ALPHA
set SMS_BIN=alpha.bin
set SMS_OS=32
goto RUN_FROM

:NT_MIPS
set SMS_BIN=mips.bin
set SMS_OS=32
goto RUN_FROM

:NT_X86
set SMS_BIN=x86.bin
set SMS_OS=32
goto RUN_FROM


:RUN_FROM
if "%OS%" == "Windows_NT"     set PATH=%PATH%;%0\..\%SMS_BIN%
if not "%OS%" == "Windows_NT" set PATH=%0\..;%0\..\%SMS_BIN%;%PATH%

REM Check for a slow network connection to the NETLOGON share and
REM possibly exit.  If not, he SETLS program is run during NET LOGON to
REM a Windows NT or LAN Manager server and is used to find the correct
REM SMS logon server and spawn the executable files for CLI_DOS and
REM INVDOS or CLI_NT and INVWIN32 located on this server.

netspeed
if not errorlevel 1 goto RUN_SETLS
if not errorlevel 2 goto RESTORE
if errorlevel 2 NLSMSG%SMS_OS% 6 /C YN /T Y,30 /M "Slow network detected. Continue"
if not errorlevel 2 goto RUN_SETLS
goto RESTORE

:RUN_SETLS

if "%OS%" == "Windows_NT" goto RUN_NT
:RUN_DOS
setls%SMS_OS% -m:E -i -p:%SMS_BIN%\CLI_DOS.EXE -pa:/p:%%SMS_UNC%%\ -pa:%SMS_VERBOSE% %SMS_VERBOSE%
setls%SMS_OS% -m:E -i -p:%SMS_BIN%\INVDOS.EXE  -pa:/l:%%SMS_UNC%%\ -pa:/i -pa:%SMS_VERBOSE% %SMS_VERBOSE%
goto RESTORE

:RUN_NT
setls%SMS_OS% -m:E -i -p:%SMS_BIN%\CLI_NT.EXE   -pa:/p:%%SMS_UNC%%\ -pa:%SMS_VERBOSE% %SMS_VERBOSE%
setls%SMS_OS% -m:E -i -p:%SMS_BIN%\INVWIN32.EXE -pa:/l:%%SMS_UNC%%\ -pa:/e -pa:/t0 -pa:/i -pa:%SMS_VERBOSE% %SMS_VERBOSE%

goto RESTORE

:OS2
echo.
%0\..\x86.bin\NLSMSGo2 5 /M "Please run SMSLS.CMD from an OS/2 window"
echo.
pause
goto END


REM SMSLS was unable to reserve the neccessary amount of environment space
REM and was unable to complete successfully. Increase the available environment
REM space and repeat logon.

:LOW_ENV
set SMS_TEMP=

REM Try to start a new command shell to procure more env space
REM but only once to avoid extra recursion.
if "%1" == "" goto newshell 

echo.
%0\..\x86.bin\NLSMSG16 7 /M "Not enough environment space"
%0\..\x86.bin\NLSMSG16 8 /M "Use the /E parameter on the shell= command in config.sys"
%0\..\x86.bin\NLSMSG16 9 /M "to increase the amount of environment space available."
pause
goto END

:newshell
command /e:2048 /c %0 retry
goto END


:RESTORE
REM Restore the previous path setting.
PATH=%SMS_P%
goto END

REM Clean up the environment variables and reset the errorlevel.
:END
set SMS_P=
set SMS_OS=

set SMS_BIN=
set SMS_VERBOSE=
if errorlevel 1 if     "%OS%" == "Windows_NT" clrlevel
if errorlevel 1 if not "%OS%" == "Windows_NT" %0\..\clrlevel
