@echo OFF

REM Copyright (C) 1994-1995 Microsoft Corporation
REM
REM This batch file is the Systems Management Server (SMS) script
REM for workstations attaching to a Windows NT or LAN Manager server.
REM It installs the SMS client components and collects hardware and
REM software inventory data.

REM This batch file is run directly from a Windows NT, LAN
REM Manager, or NetWare SMS logon server for DOS, Windows, and Windows
REM NT workstations. To run directly from an SMS logon server, the user
REM must make a network connection (drive mapping) using an available
REM drive letter and then change the current drive to this network
REM drive. This connection must be to SMS_SHR for a Windows NT or LAN
REM Manager server, or to the SMS-volume:SMS-directory\LOGON.SRV
REM directory for a NetWare server.  This batch file can also be run
REM from the Windows95 Explorer, or with a UNC such as 
REM \\SMS-server\SMS_SHR\RUNSMS.

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_SHR 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.

if not exist %0\..\dosver.com goto NOARG0
%0\..\dosver
if errorlevel 13 goto OS2
goto DOS_BIN

:NOARG0
REM this should only occur on Netware machines running pure netx
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 The SETLS program will spawn the executable files for CLI_DOS and
REM INVDOS or CLI_NT and INVWIN32 located on this server.

:RUN_SETLS

if "%OS%" == "Windows_NT" goto RUN_NT

:RUN_DOS
if not exist %0\..\%SMS_BIN%\setls%SMS_OS%.exe goto NOPATHARG0

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

:NOPATHARG0
REM this should only occur on Netware machines running pure netx
%SMS_BIN%\setls%SMS_OS% -m:E -i -p:%SMS_BIN%\CLI_DOS.EXE -pa:/p:%%SMS_UNC%%\ -pa:%SMS_VERBOSE% %SMS_VERBOSE%
%SMS_BIN%\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.
NLSMSG%SMS_OS% 10 /M "Please run RUNSMS.CMD from an OS/2 window"
echo.
pause
goto END


REM RUNSMS was unable to reserve the neccessary amount of environment space
REM and was unable to complete successfully. Increase the available environment
REM space and retry this batch file.

: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. The second call to the
REM batch file will have a command line parameter.
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.
:END
set SMS_P=
set SMS_OS=

set SMS_BIN=
set SMS_VERBOSE=
