Page 1 of 2 12>
Topic Options
#7928 - 2001-04-03 06:10 PM Windows 2000 OS identifier
Anonymous
Unregistered


Here's a simple question from a simple mind.

You are familiar with the statement:
IF "%OS%" == "windows_NT"

What is the correct identifier for Windows 2000?

Top
#7929 - 2001-04-03 08:12 PM Re: Windows 2000 OS identifier
Anonymous
Unregistered


If you are using kiXtart, just use the macros

SELECT ; Checks what OS you are running.
CASE ((@INWIN = 1) AND (@DOS = 5.0))
$OS = "Win2K"
CASE ((@INWIN = 1) AND (@DOS = 4.0))
IF $Systype = "LanmanNT" OR $SysType = "ServerNT"
$OS = NT4server
ELSE
$OS = "NT4wksta"
ENDIF
CASE ((@INWIN = 2) AND (@DOS >= 4.10))
$OS = "Win98"
CASE ((@INWIN = 2) AND (@DOS = 4.0))
$OS = "Win95"
ENDSELECT

Travis

Top
#7930 - 2001-04-03 10:10 PM Re: Windows 2000 OS identifier
cmarti Offline
Hey THIS is FUN

Registered: 2001-02-26
Posts: 297
Loc: Little Rock, AR
2000 machines will also have an entry 'Microsoft Windows 2000" in the registry at "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","ProductName")
Top
#7931 - 2001-04-05 06:25 AM Re: Windows 2000 OS identifier
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

A more detail list of$os versions is possible.
For ideas look also to our script os.kix
from out site
http://home.wanadoo.nl/scripting
It returns to types:


  • long name: os.version + os.productname + service.pack
  • short name: os.version (f.e. W2K, NT4, W95, W98, ME)

Greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#7932 - 2001-10-29 07:02 PM Re: Windows 2000 OS identifier
Anonymous
Unregistered


What about if you want to test for 2K in DOS (logon.bat) instead of in Kixtart?
Top
#7933 - 2001-10-29 08:22 PM Re: Windows 2000 OS identifier
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The output of VER will show:


C:\>ver

Microsoft Windows 2000 [Version 5.00.2195]

C:\>


Pipe it to Find, and Bob's your uncle.

[ 29 October 2001: Message edited by: LLigetfa ]

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#7934 - 2001-10-29 10:45 PM Re: Windows 2000 OS identifier
Anonymous
Unregistered


What do you mean with "Pipe it to Find"?

Martijn

Top
#7935 - 2001-10-29 11:12 PM Re: Windows 2000 OS identifier
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Sample DOS TEST.CMD

code:

ver | find /i "Version 5.00"
If errorLevel 0 goto Found
GoTo Done
:Found
Echo Windows 2000 DOS Ver 5.00
one

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#7936 - 2001-10-30 11:22 AM Re: Windows 2000 OS identifier
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
mmletzko,

No need to shell out or run another program to locate Windows 2000. This batch file should do the trick.

code:
@ECHO OFF
if not "%ALLUSERSPROFILE%" == "" goto found
GOTO END

:FOUND
ECHO Found Windows 2000
REM Or what ever command you want to run.
GOTO END

:END


The environment variable %ALLUSERSPROFILE% should not exist on any of the other Windows OS types.

Martijn,

Pipe normally means to redirect the output to another program to perform another task with it. However, using this batch file it is not needed.

HTH...

[ 30 October 2001: Message edited by: NTDOC ]

Top
#7937 - 2001-10-31 08:00 PM Re: Windows 2000 OS identifier
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Hello mmletzko,

Did this work out for you, or did anyone else test this and confirm it works?

Top
#7938 - 2001-11-05 10:21 AM Re: Windows 2000 OS identifier
Anonymous
Unregistered


NTDOC,

This seems to work. I added a sub to test if win2k is not found. I tested this on a win95-machine and an Nt-server-machine. It's a simple but yet effective test.

Here's the batch I tested:

code:
@Echo OFF
If not "%ALLUSERSPROFILE%" == "" Goto FOUND
If "%ALLUSERSPROFILE%" == "" Goto NOTFOUND
Goto END

:FOUND
Echo Found Windows 2000
Pause
Goto END

:NOTFOUND
Echo Windows 2000 not found
Pause
Goto END

:END


Martijn

Top
#7939 - 2001-11-05 10:24 AM Re: Windows 2000 OS identifier
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Good, glad to hear it works Martin
Top
#7940 - 2001-11-06 09:18 AM Re: Windows 2000 OS identifier
chaicka Offline
Lurker

Registered: 2001-11-06
Posts: 1
How about Windows XP?

If I have not remember wrongly, winXP cannot recognize an "If" statement. I tried with a simple batch file, and it failed.

Top
#7941 - 2001-11-06 10:57 PM Re: Windows 2000 OS identifier
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Hello chaicka,

Please give this a try and let me know how it goes.

The following code can be used to find the current release version of Windows XP from a batch file. This may need to be altered for other non English languages and/or when XP is updated.

NOTE:
The line to check for Windows 9x must be first otherwise you'll get an error because Windows 9x does not understand the FOR command as used here

code:
@ECHO OFF
IF NOT "%OS%" == "Windows_NT" GOTO WIN9X
for /f "Tokens=*" %%i in ('ver') do ( IF "%%i" == "Microsoft Windows XP [Version 5.1.2600]" GOTO XP)
IF not "%ALLUSERSPROFILE%" == "" GOTO WIN2K
IF "%OS%" == "Windows_NT" GOTO NT4
GOTO END

:XP
ECHO Found Windows XP
REM Or what ever command you want to run.
GOTO END

:WIN2K
ECHO Found Windows 2000
REM Or what ever command you want to run.
GOTO END

:NT4
ECHO Found Windows NT 4
REM Or what ever command you want to run.
GOTO END

:WIN9X
ECHO Found Windows 9x
REM Or what ever command you want to run.
GOTO END

:END


Please post your test results. All my batch files still work in XP so I don't think it is something caused by XP.

[ 06 November 2001: Message edited by: NTDOC ]

Top
#7942 - 2001-11-08 07:34 PM Re: Windows 2000 OS identifier
Pelussa Offline
Lurker

Registered: 2001-11-08
Posts: 1
How to Determine the OS Type in a Logon Script


PSS ID Number: Q190899
Article last modified on 12-15-2000

WINDOWS:; Win2000:95; winnt:3.51,4.0

======================================================================
-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Windows NT Server versions 3.51, 4.0
- Microsoft Windows NT Workstation versions 3.51, 4.0
- Microsoft Windows NT Server, Enterprise Edition version 4.0
- Microsoft Windows NT Server version 4.0, Terminal Server Edition
- Microsoft Windows 95
- Microsoft Windows 98
-------------------------------------------------------------------------------

SUMMARY
=======

Often, administrators would like to run software on only their Windows 95 or
Windows 98 clients, or their Windows NT Workstation clients. They may not want
to run some logon script commands on their Windows NT Server computers or domain
controllers.

MORE INFORMATION
================

Using a simple batch file and a small executable file, you can tell if the
client is a:

- Windows 95 or Windows 98 client
- Windows NT workstation
- Windows 2000 Professional installation
- Windows NT Server non-domain controller
- Windows 2000 Server non-domain controller
- Windows NT Server domain controller
- Windows 2000 Server domain controller
- Windows NT Enterprise/Terminal Server domain controller
- Windows NT Enterprise/Terminal Server non-domain controller

Copy the following text to a batch file:

@echo off
REM Batch file to detect OS
REM ----------------------------------
if Windows_NT == %OS% goto WINNT
echo You are not running Windows NT (Windows 95/98 perhaps?)
goto END

:WINNT
gettype.exe

if errorlevel=9 goto FILENOTFOUND

echo You are running Windows NT.
echo More Specifically:
echo.

if ERRORLEVEL=8 goto EIGHT
if ERRORLEVEL=7 goto SEVEN
if ERRORLEVEL=6 goto SIX
if ERRORLEVEL=5 goto FIVE
if ERRORLEVEL=4 goto FOUR
if ERRORLEVEL=3 goto THREE
if ERRORLEVEL=2 goto TWO
if ERRORLEVEL=1 goto ONE

:FILENOTFOUND
echo.
echo Gettype not found.
echo.
goto END

:EIGHT
echo Windows NT Enterprise/Terminal Server Non-Domain Controller
goto END

:SEVEN
echo Windows NT Enterprise/Terminal Server Domain Controller
goto END

:SIX
echo Windows 2000 Server Domain Controller
goto END

:FIVE
echo Windows NT Server Domain Controller
goto END

:FOUR
echo Windows 2000 Server Non-Domain Controller
goto END

:THREE
echo Windows NT Server Non-Domain Controller
goto END

:TWO
echo Windows 2000 Professional installation
goto END

:ONE
echo Windows NT Workstation
goto END

:END
pause

Copy the Gettype.exe file and the batch file to the target workstations and run
the batch file.

You can obtain Gettype.exe version 4.0 from Microsoft Product Support Services.

Gettype.exe works by querying the registry for the installation type and setting
the DOS ERRORLEVEL appropriately:

- Returns 1 for Windows NT Workstation.
- Returns 2 for Windows 2000 Professional.
- Returns 3 for Windows NT Server non-domain controller.
- Returns 4 for Windows 2000 Server non-domain controller.
- Returns 5 for Windows NT Server domain controller.
- Returns 6 for Windows 2000 Server domain controller.
- Returns 7 for Windows NT Enterprise/Terminal Server domain controller.
- Returns 8 for Windows NT Enterprise/Terminal Server non-domain controller.

Silent mode can be set with the /s parameter. This tool can also be run against
remote computers.

Top
#7943 - 2001-11-08 11:32 PM Re: Windows 2000 OS identifier
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Hello Pelussa and welcome to the board.

Yes, I've seen this article from Microsoft, but it assumes the usage of an external program, which means that program would also have to be available to any and all clients that use it.

It also does not deal with XP which a couple of users asked how they could do it from a batch file. The method I gave has this ability.

KiXtart 2001 has all of this functionlity built-in (Thanks Rudd), but the question was also asked how it could be done in DOS.

Thanks again though for the information as I'm sure it is or may be useful to someone, sometime.

[ 08 November 2001: Message edited by: NTDOC ]

Top
#7944 - 2001-11-09 01:17 AM Re: Windows 2000 OS identifier
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
GETTYPE would require the use of the utility from the Resource Kit.

Has anybody seen the Resource Kit from XP yet?

Doc - I took your code and modified it.

code:

::@ECHO OFF
IF NOT "%OS%" == "Windows_NT" GOTO WIN9X

VER|FIND /I "2000" && IF %ERRORLEVEL% EQU 0 GOTO WIN2K || FIND /I "XP" && IF %ERRORLEVEL% EQU 0 GOTO XP
IF "%OS%" == "Windows_NT" GOTO NT4

GOTO END

:XP
ECHO Found Windows XP
REM Or what ever command you want to run.
GOTO END

:WIN2K
ECHO Found Windows 2000
REM Or what ever command you want to run.
GOTO END

:NT4
ECHO Found Windows NT 4
REM Or what ever command you want to run.
GOTO END

:WIN9X
ECHO Found Windows 9x
REM Or what ever command you want to run.
GOTO END

:END
PAUSE


Thanks!

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#7945 - 2001-11-09 03:03 AM Re: Windows 2000 OS identifier
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Kent,

Cool idea, but the second pipe is being ignored. When run on XP it says it found NT 4

I'll see if I can get it to work later on.

Top
#7946 - 2001-11-09 07:33 AM Re: Windows 2000 OS identifier
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
OK, time for humble pie. My previous example is wrong. Here is corrected form:
code:

ver | find /i "Version 5.00"
If NOT errorLevel 1 goto Found
GoTo Done
:Found
Echo Windows 2000 DOS Ver 5.00
one


I forgot that "IF ERRORLEVEL 0" actually means "IF ERRORLEVEL > 0".

Darn, losing what little credibility I may have.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#7947 - 2001-11-09 07:43 AM Re: Windows 2000 OS identifier
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
While I'm at it, may as well give Kent's one liner a go. How about this?

code:

VER|FIND /I "2000" && IF %ERRORLEVEL% EQU 0 GOTO WIN2K || VER|FIND /I "XP" && IF %ERRORLEVEL% EQU 0 GOTO XP

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 980 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.07 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org