Computing.Net > Forums > Windows 95/98 > Batch file to check os

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to check os

Reply to Message Icon

Name: jvandel
Date: April 19, 2001 at 06:23:04 Pacific
Comment:

I am looking for a batch file to check the operating system on a pc from nt network logon. VIA 95,98,2000, or nt. Thanks in advance



Sponsored Link
Ads by Google

Response Number 1
Name: Nodoz
Date: April 19, 2001 at 11:06:43 Pacific
Reply:

Wrote it just now. some notes are included. if you are trying to find the client's OS and version from a login script, this should trick. The "@echo off" should be the first line. The ":end" should be the last. Here goes.

@echo off

REM -Check OS-----(slapdash by Nodoz)-
REM Uses FIND.exe to interpret output
REM from ver command and runs specific
REM cammands based on result.
REM ---------------------------------
REM WARNING: I have only tested this
REM on a windows 2000 machine and cant
REM be sure if i guessed the ver output
REM right on every Microsoft OS. be sure
REM to test it on all the OS's you plan
REM to run it on before implementation.
REM (I'm pretty darn sure it's right)
REM ----------------------------------
REM NOTE: errorlevel 1 after find means
REM "did not find" or "find operation
REM failed"
REM ----------------------------------

REM must use FIND with absolute pathname
REM because NT will kill the script if
REM FIND isn't where we say it is
REM (in case environment path not set)
REM so first we have to find FIND.exe

:findfind
if "%windir%" == "" goto notset
if exist %windir%\command\find.exe goto On9X
if exist %windir%\system32\find.exe goto OnNT
echo ***Could not find FIND.EXE***
echo looked in:
echo %windir%\command\
echo %windir%\system32\
echo.
echo %%windir%% is set to %windir%
goto BADOS


:OnNT
REM -start checking likely NT machine-
:checkNTfor2000
ver|%windir%\system32\find.exe "Windows 2000"
if errorlevel 1 goto checkNTforNT
goto run2000

:checkNTforNT
ver|%windir%\system32\find.exe "Windows NT"
if errorlevel 1 goto checkNTfor95
goto runNT

:checkNTfor95
REM -check for wierd 9X setup-
ver|%windir%\system32\find.exe "Windows 95"
if errorlevel 1 goto checkNTfor98
goto run95

:checkNTfor98
ver|%windir%\system32\find.exe "Windows 98"
if errorlevel 1 goto BADOS
goto run98

:On9X
REM -start checking likely 9X machine-
:check9Xfor95
ver|%windir%\command\find.exe "Windows 95"
if errorlevel 1 goto check9Xfor98
goto run95

:check9Xfor98
ver|%windir%\command\find.exe "Windows 98"
if errorlevel 1 goto check9Xfor2000
goto run98

:check9Xfor2000
REM -check for wierd NT setup-
ver|%windir%\command\find.exe "Windows 2000"
if errorlevel 1 goto check9XforNT
goto run2000

:check9XforNT
ver|%windir%\command\find.exe "Windows NT"
if errorlevel 1 goto BADOS
goto runNT


:notset
echo ***Can't find %%windir%% variable!***
echo ***Couldn't search for FIND.EXE***
echo.

:BADOS
echo.
echo.
echo.
echo.
echo.
echo This script doesn't support this OS
echo Contact your network administrator.
echo.
pause
goto end


REM -Here, we run OS specific tasks-
:run95
echo This is a Windows 95 machine.
REM *****Win95 specific tasks here*****
goto runend

:run98
echo This is a Windows 98 machine.
REM *****Win98 specific tasks here*****
goto runend

:run2000
echo This is a Windows 2000 machine.
REM *****Win2000 specific tasks here*****
goto runend

:runNT
echo This is a Windows NT machine.
REM *****WinNT specific tasks here*****
goto runend

:runend
REM *****RUNSUCCESS tasks here*****

:end


0

Response Number 2
Name: jvandel
Date: April 19, 2001 at 11:30:41 Pacific
Reply:

This is the best response I jave received yet. It work great on 95,98,2000 haven't test nt but I am sure it will. Thank you very!! much.


0

Response Number 3
Name: Nodoz
Date: April 19, 2001 at 15:33:58 Pacific
Reply:

Thanks for the positive response, jvandel. much appreciated


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 95/98 Forum Home


Sponsored links

Ads by Google


Results for: Batch file to check os

BATCH FILE TO LAUNCH DIAL-UP CONNECTION www.computing.net/answers/windows-95/batch-file-to-launch-dialup-connection/102177.html

batch file to clean system www.computing.net/answers/windows-95/batch-file-to-clean-system/133777.html

batch file for copying files via sc www.computing.net/answers/windows-95/batch-file-for-copying-files-via-sc/125849.html