Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Detecting the current OS

54 views
Skip to first unread message

Thomas Steinbach

unread,
Mar 6, 2009, 2:43:55 PM3/6/09
to
Hello NG,

how can I determine in a Batch-Scipt which OS
is running? What technics do you use and prefer?
Win 2000 or OS prior to Win 2000, Win XP
or Win Vista and Win7

Thomas

Frank P. Westlake

unread,
Mar 6, 2009, 3:01:01 PM3/6/09
to
"Thomas Steinbach" news:goruhs$ad6$03$1...@news.t-online.com...

> how can I determine in a Batch-Scipt which OS
> is running?

With the VER command. Use FOR /F to get the output text.

Frank


T Lavedas

unread,
Mar 6, 2009, 3:04:28 PM3/6/09
to
On Mar 6, 2:43 pm, "Thomas Steinbach" <steinb...@gmx-topmail.de>
wrote:

A common way is to parse/match the output of the VER statement.

Find Timo Salmi's FAQ posting.

Tom Lavedas
***********
http://there.is.no.more/tglbatch/

ten.n...@virgin.net

unread,
Mar 6, 2009, 4:12:28 PM3/6/09
to
On Fri, 6 Mar 2009 12:04:28 -0800 (PST), T Lavedas wrote:

> Find Timo Salmi's FAQ posting.
>
> Tom Lavedas

To save you looking for it:
http://www.netikka.net/tsneti/info/tscmd004.htm

Matthias Tacke

unread,
Mar 6, 2009, 4:47:09 PM3/6/09
to
One method not contained in Timo's FAQ is Herbert Kleebauer's gver.
<http://groups.google.com/group/alt.msdos.batch/msg/f90211839334f865>

--
Regards
Matthias

0x0...@gmail.com

unread,
Mar 6, 2009, 5:53:47 PM3/6/09
to
%comspec% -version

Timo Salmi

unread,
Mar 6, 2009, 10:47:12 PM3/6/09
to
0x0...@gmail.com wrote:
> %comspec% -version

The -version is superfluous. Besides, one needs an exit after that.

All the best, Timo

--
Prof. Timo Salmi mailto:t...@uwasa.fi ftp & http://garbo.uwasa.fi/
Hpage: http://www.uwasa.fi/laskentatoimi/english/personnel/salmitimo/
Department of Accounting and Finance, University of Vaasa, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm

FileGod

unread,
Mar 7, 2009, 1:31:45 PM3/7/09
to
Matthias Tacke <Matt...@Tacke.de> wrote:
>Thomas Steinbach wrote:
> Hello NG,
>
> how can I determine in a Batch-Scipt which OS
> is running? What technics do you use and prefer?
> Win 2000 or OS prior to Win 2000, Win XP
> or Win Vista and Win7

Sorry, I missed the original question but this batch file I found a few
months ago might help you...

@ECHO OFF

:: Win9x checks ::::::::::::

VER |find /i "Windows 95" >NUL
IF NOT ERRORLEVEL 1 GOTO W9598ME

VER |find /i "Windows 98" >NUL
IF NOT ERRORLEVEL 1 GOTO W9598ME

VER |find /i "Windows Millennium" >NUL
IF NOT ERRORLEVEL 1 GOTO W9598ME

:: NT/XP checks ::::::::::::
VER | find "XP" > nul
IF %errorlevel% EQU 0 GOTO s_win_XP

VER | find "2000" > nul
IF %errorlevel% EQU 0 GOTO s_win_2000

VER | find "NT" > nul
IF %errorlevel% EQU 0 GOTO s_win_NT

ECHO Unknown OS !
GOTO :EOF

:: Win9x commands ::::::::::::

:W9598ME
ECHO Win9x commands go here
GOTO :EOF

:W98
ECHO Win98 commands go here
GOTO :EOF

:: NT/XP commands ::::::::::::

:s_win_XP
ECHO XP commands go here
goto :eof

:s_win_2000
ECHO WIN2K commands go here
goto :eof

:s_win_NT
ECHO NT4 commands go here
goto :eof

:EOF (End-of-file)Service Pack Version

I found this here:
http://www.fortypoundhead.com/showcontent.asp?ArtID=837
I am sorry it does not cover DOS.
http://www.filegod.netfirms.com

0x0...@gmail.com

unread,
Mar 7, 2009, 1:35:12 PM3/7/09
to
I was wrong, indeed: -version parameter is not valid, therefore, cmd
ignores it and just starts a new nested interpreter.

As compensation, devise a new way to determine the version, and the
result is the most full.

For example, command 'ver' gets: Microsoft Windows XP
and this code gets: Microsoft Windows XP Professional

If not the first method uses the second command is command 'ver'.


:::::::::::::::::::::::::::::::::::::::::::::::::::::Code::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off

for /f "tokens=* usebackq eol=" %%o in ("%windir%\system32\eula.txt")
do ^
set "_os__version_=%%o" & goto :continue:
:continue:
if defined _os__version_ (echo.%_os__version_:®=%) else ^
for /f "tokens=1 delims=[ eol=" %%o in ('ver') do echo.%%o

pause
:::::::::::::::::::::::::::::::::::::::::::::::::::::Code::::::::::::::::::::::::::::::::::::::::::::::::::

0x0...@gmail.com

unread,
Mar 7, 2009, 1:45:39 PM3/7/09
to
Sorry, this is correct code:

:::::::::::::::::::::::::::::::::::::::::::::::::::::Code::::::::::::::::::­::::::::::::::::::::::::::::::::

@echo off

for /f "tokens=* eol=" %%o in (%windir%\system32\eula.txt) do (


set "_os__version_=%%o" & goto :continue:

)
:continue:
if defined _os__version_ (echo.%_os__version_:®=%) else (


for /f "tokens=1 delims=[ eol=" %%o in ('ver') do echo.%%o

)

pause

:::::::::::::::::::::::::::::::::::::::::::::::::::::Code::::::::::::::::::­::::::::::::::::::::::::::::::::

Timo Salmi

unread,
Mar 7, 2009, 3:06:20 PM3/7/09
to
0x0...@gmail.com wrote:
> @echo off
> for /f "tokens=* usebackq eol=" %%o in ("%windir%\system32\eula.txt")
> do ^
(etc)

I am sorry to shoot your effort down, but it makes bad logical sense,
since your code is heavily version dependent. It is one task that should
be done with as version independent code as ever possible.

Message has been deleted

0x0...@gmail.com

unread,
Mar 7, 2009, 7:43:03 PM3/7/09
to
On 7 mar, 17:06, Timo Salmi <t...@uwasa.fi> wrote:
> 0x0...@gmail.com wrote:
> > @echo off
> > for /f "tokens=* usebackq eol=" %%o in ("%windir%\system32\eula.txt")
> > do ^
>
> (etc)
>
> I am sorry to shoot your effort down, but it makes bad logical sense,
> since your code is heavily version dependent. It is one task that should
> be done with as version independent code as ever possible.
>
>     All the best, Timo
>
> --
> Prof. Timo Salmi   mailto:t...@uwasa.fi    ftp &http://garbo.uwasa.fi/

> Hpage:http://www.uwasa.fi/laskentatoimi/english/personnel/salmitimo/
> Department of Accounting and Finance,   University of Vaasa,  Finland
> Useful CMD script trickshttp://www.netikka.net/tsneti/info/tscmd.htm


first, it bothers me to quote from the wrong code, when it could have
quoted the correct code I published 10 minutes later (and the answer
is two hours later).

Try it on Windows NT, 2000, XP and Vista, and I will see which version
is so dependent.

Not always be thinking about compatibility programmed, for example, I
do not care to run this code on Windows 98 or DOS, why not just use my
batch in these systems, for example, the command else does not exist
in Windows 98.

My version, delivers more complete, that all that you put in your faq.

Scott Seligman

unread,
Mar 7, 2009, 11:50:22 PM3/7/09
to
0x0...@gmail.com wrote:
>Sorry, this is correct code:
>
>
>@echo off
>
>for /f "tokens=* eol=" %%o in (%windir%\system32\eula.txt) do (
>set "_os__version_=%%o" & goto :continue:
>)
>:continue:
>if defined _os__version_ (echo.%_os__version_:®=%) else (
>for /f "tokens=1 delims=[ eol=" %%o in ('ver') do echo.%%o
>)
>
>pause

This only displays "Microsoft Windows" on either one of my Vista
boxes.

I suppose that's technically correct, but not terribly helpful :)

--
--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
Money often costs too much.
-- Ralph Waldo Emerson

0x0...@gmail.com

unread,
Mar 8, 2009, 12:43:59 AM3/8/09
to
He devised a new way to know if the operating system is NT or 9x
family.

::::::::::::::::::::Code:::::::::::::::::::::::
set _osfamily=nt
ver /r 2>nul
if not errorlevel 1 set _osfamily=9x
echo osfamily:%_osfamily%
::::::::::::::::::::Code:::::::::::::::::::::::

ver /r is undocumented in windows 9x family. This not exist in windows
nt family.
ver /r 2>nul set errorlevel to 1 in nt family, but unset in windows 9x
family.

This can be useful.

All the best, 0x0309

Todd Vargo

unread,
Mar 8, 2009, 1:01:12 AM3/8/09
to
0x0...@gmail.com wrote:

> Timo Salmi wrote:
>> 0x0...@gmail.com wrote:
>>> @echo off
>>> for /f "tokens=* usebackq eol=" %%o in
>>> ("%windir%\system32\eula.txt") do ^
>>
>> (etc)
>>
>> I am sorry to shoot your effort down, but it makes bad logical sense,
>> since your code is heavily version dependent. It is one task that
>> should be done with as version independent code as ever possible.
>>
>
> first, it bothers me to quote from the wrong code, when it could have
> quoted the correct code I published 10 minutes later (and the answer
> is two hours later).

You apperantly don't understand newsgroup posting.

>
> Try it on Windows NT, 2000, XP and Vista, and I will see which version
> is so dependent.

No, YOU do your own testing prior to publishing.

>
> Not always be thinking about compatibility programmed, for example, I
> do not care to run this code on Windows 98 or DOS, why not just use my
> batch in these systems, for example, the command else does not exist
> in Windows 98.
>
> My version, delivers more complete, that all that you put in your faq.

Your later versions were also version dependent as well as questionable.
Reading eula.txt for OS version is a haphazard approach. While you may not
care about Windows 98 or DOS systems, there are others reading this
discussion who may.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

0x0...@gmail.com

unread,
Mar 8, 2009, 1:35:48 AM3/8/09
to

At least I do, how many times I found the operating system has to
differentiate between Windows NT and 2000 or XP, for example because
the command output Reg.exe query is different but if you are looking
for a script compatible with command.com Windows 98 SE lose all of the
NT, eg nesting of commands, set /p, for /f, else, & && || etc.

The code that reads eula.txt rioja tested on Windows 2000 and XP,
although a user has already said that it does not work in Vista. In
Windows 98 the file is called LICENSE.TXT but can not be parsed with a
for /f

The universal detector Timo said: Unknow in my Windows XP.


0x0...@gmail.com

unread,
Mar 8, 2009, 1:51:39 AM3/8/09
to
I will make a universal windows dos detector version, give me a three
days please.

Timo Salmi

unread,
Mar 8, 2009, 4:58:58 AM3/8/09
to
0x0...@gmail.com wrote:
> I will make a universal windows dos detector version, give me a three
> days please.

Is there a special reason to re-solve a problem that already has been
solved? http://www.netikka.net/tsneti/info/tscmd004.htm

Not that new or revisited solutions wouldn't always be welcome.

All the best, Timo

--
Prof. Timo Salmi mailto:t...@uwasa.fi ftp & http://garbo.uwasa.fi/

Oswald Low

unread,
Mar 8, 2009, 7:36:00 AM3/8/09
to
On Sun, 08 Mar 2009 08:58:58 -0000, Timo Salmi <t...@uwasa.fi> wrote:

> 0x0...@gmail.com wrote:
>> I will make a universal windows dos detector version, give me a three
>> days please.
>
> Is there a special reason to re-solve a problem that already has been
> solved? http://www.netikka.net/tsneti/info/tscmd004.htm
>
> Not that new or revisited solutions wouldn't always be welcome.
>
> All the best, Timo
>

Well there's the internal "DOS" version available via int 21 functions, as
long as you're on an intel platform.
I felt somone in this group (or AMB) had made some ascii assembler code
about 5 years ago, but I can't find it now.(later) Oh, seems I did keep it.

One of Herbert's? ah, found it

http://groups.google.com/group/comp.os.msdos.programmer/browse_thread/thread/62ad3649fca2d2bf?q=PlatformId+gver


--
Lovely plumage

0x0...@gmail.com

unread,
Mar 8, 2009, 7:53:20 AM3/8/09
to
Here is my improve version of Timo Salmi detector:
http://sites.google.com/site/ntbatchsite/universal-batch-operating-system-detector
(I put here because the posting in this groups alter the code.)

We tested on Windows 98, 2000, 2003, XP and tried the syntax in MS DOS
7.10, also tried it using cmd.exe from Windows NT 4 server.
I have not tested on Vista, but I think it should work.

The version of the Timo is limited by language, "software version" is
in my windows "versión del programa", because it did not work, so I
decided to make an improvement for the family nt can be executed in
any language.

Frank P. Westlake

unread,
Mar 8, 2009, 8:15:48 AM3/8/09
to
<0x0309@>
news:8fd8d47f-a16b-4d53...@c36g2000yqn.googlegroups.com...

> Here is my improve version of Timo Salmi detector:

> I have not tested on Vista, but I think it should work.

In Windows Vista SP 1 it prints:

Operating System: Windows Vista or Seven

But If you get to that point you can run VER and see that it is not version
seven. My Windows Vista SP1 prints "Microsoft Windows [Version 6.0.6001]",
but I have access to only this one computer so I don't know if the service
pack is encoded in the version number.

Frank

0x0...@gmail.com

unread,
Mar 8, 2009, 8:29:50 AM3/8/09
to
run net config workstation|find /i "Windows", perhaps need authorizate
this command.
windows seven is kernel 6.1

Now that I've written all the code, I've noticed that you only need
Timo code is simply:

Replace:
"Software version"

by:

"Windows"

It was so simple. xD


Timo Salmi

unread,
Mar 8, 2009, 10:15:43 AM3/8/09
to
0x0...@gmail.com wrote:
> Here is my improve version of Timo Salmi detector:
> http://sites.google.com/site/ntbatchsite/universal-batch-operating-system-detector
> (I put here because the posting in this groups alter the code.)

I've added a link to your posting, into my item #4.

0x0...@gmail.com

unread,
Mar 8, 2009, 5:30:47 PM3/8/09
to
I updated the script, I have corrected the detection of Windows
Millennium, and I modified a simple label in capital letters.

0x0...@gmail.com

unread,
Mar 8, 2009, 8:40:31 PM3/8/09
to
In:
http://sites.google.com/site/ntbatchsite/universal-batch-operating-system-detector

also can view the updated script (beta 3), and download iso image (52
KB) with os.bat for testing in operating systems with virtual machine.
I test in MS-DOS 7.10 and Windows 95, and works.


Oswald Low

unread,
Mar 9, 2009, 2:50:49 PM3/9/09
to

I can't see why you test "if errorlevel 0"; it's generally true

also I get (Cut-n-paste)


C:\>net config workstation |find "version"
Software version Windows 2002

C:\>ver

Microsoft Windows XP [Version 5.1.2600]

C:\>


--
Lovely plumage

Frank P. Westlake

unread,
Mar 9, 2009, 3:23:20 PM3/9/09
to
"Scott Seligman" news:goviqe$bcu$1...@panix3.panix.com...

> This only displays "Microsoft Windows" on either one of my Vista
> boxes.

Which Vista's do you have? I suspect VER. will say the same version on each
but it looks like NET will be useful in determining which implimentation is
being used.

For those who wish to know, on my machine:

Windows Vista Home Basic Service Pack 1:
----------------------------------------
VER
Microsoft Windows [Version 6.0.6001]

NET config workstation |find "version"
Software version Windows Vista (TM) Home Basic


Frank

Frank P. Westlake

unread,
Mar 9, 2009, 4:03:48 PM3/9/09
to
I don't recall seeing %SystemRoot%\System32\SYSTEMINFO.EXE in any previous
versions so I'll take the chance that it's new in Vista and present it to
those of you who don't have Vista but need to be prepared for it.

**********************************************************************
SYSTEMINFO /?
SYSTEMINFO [/S system [/U username [/P [password]]]] [/FO format] [/NH]

Description:
This tool displays operating system configuration information for
a local or remote machine, including service pack levels.

Parameter List:
/S system Specifies the remote system to connect to.

/U [domain\]user Specifies the user context under which
the command should execute.

/P [password] Specifies the password for the given
user context. Prompts for input if omitted.

/FO format Specifies the format in which the output
is to be displayed.
Valid values: "TABLE", "LIST", "CSV".

/NH Specifies that the "Column Header" should
not be displayed in the output.
Valid only for "TABLE" and "CSV" formats.

/? Displays this help message.

Examples:
SYSTEMINFO
SYSTEMINFO /?
SYSTEMINFO /S system
SYSTEMINFO /S system /U user
SYSTEMINFO /S system /U domain\user /P password /FO TABLE
SYSTEMINFO /S system /FO LIST
SYSTEMINFO /S system /FO CSV /NH

**********************************************************************

Here's the output on my computer. In all cases where there is a question
mark (?) it has been added by me to disguise something that may be sensitive
information, but it only replaces an existing character.

Note: First line of STDOUT is blank because progress information is printed
to either the console or to STDERR while collecting the data.
**********************************************************************

Host Name: FRANK-P
OS Name: Microsoft® Windows Vista™ Home Basic
OS Version: 6.0.6001 Service Pack 1 Build 6001
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Registered Owner: Frank
Registered Organization:
Product ID: ?????-OEM-???????-?????
Original Install Date: 2009-01-14, 20:05:56
System Boot Time: 2009-03-08, 06:19:09
System Manufacturer: Sony Corporation
System Model: VGN-P530H
System Type: X86-based PC
Processor(s): 1 Processor(s) Installed.
[01]: x86 Family 6 Model 28 Stepping 2
GenuineIntel ~800 Mhz
BIOS Version: INSYDE R1250U3, 2008-12-08
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume2
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
Time Zone: (GMT-08:00) Pacific Time (US & Canada)
Total Physical Memory: 2,037 MB
Available Physical Memory: 821 MB
Page File: Max Size: 4,325 MB
Page File: Available: 3,097 MB
Page File: In Use: 1,228 MB
Page File Location(s): C:\pagefile.sys
Domain: WORKGROUP
Logon Server: \\FRANK-P
Hotfix(s): 58 Hotfix(s) Installed.
[01]: 928439
[02]: 942567
[03]: 917607
[04]: KB905866
[05]: KB935509
[06]: KB937287
[07]: KB938371
[08]: KB938464
[09]: KB948590
[10]: KB948609
[11]: KB948610
[12]: KB948643
[13]: KB948881
[14]: KB949466
[15]: KB950582
[16]: KB950762
[17]: KB950974
[18]: KB951066
[19]: KB951072
[20]: KB951698
[21]: KB951978
[22]: KB952069
[23]: KB952287
[24]: KB952709
[25]: KB952714
[26]: KB953029
[27]: KB953155
[28]: KB953733
[29]: KB954154
[30]: KB954211
[31]: KB954366
[32]: KB954459
[33]: KB955020
[34]: KB955069
[35]: KB955302
[36]: KB955839
[37]: KB956390
[38]: KB956391
[39]: KB956802
[40]: KB956841
[41]: KB957095
[42]: KB957097
[43]: KB957200
[44]: KB957321
[45]: KB957388
[46]: KB957526
[47]: KB958481
[48]: KB958483
[49]: KB958623
[50]: KB958624
[51]: KB958644
[52]: KB958687
[53]: KB959108
[54]: KB959130
[55]: KB959772
[56]: KB960715
[57]: KB961260
[58]: 940157
Network Card(s): 2 NIC(s) Installed.
[01]: Atheros AR928X Wireless Network Adapter
Connection Name: Wireless Network
Connection
DHCP Enabled: Yes
DHCP Server: 192.168.0.1
IP address(es)
[01]: 192.168.0.184
[02]: fe80::b41c:20b1:1c72:f59c
[02]: Bluetooth Device (Personal Area Network)
Connection Name: Bluetooth Network
Connection
Status: Media disconnected
**********************************************************************
SYSTEMINFO|FindStr /b "OS"
OS Name: Microsoftr Windows VistaT Home Basic
OS Version: 6.0.6001 Service Pack 1 Build 6001
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
**********************************************************************

Frank

0x0...@gmail.com

unread,
Mar 9, 2009, 6:31:16 PM3/9/09
to
Soon publish a new revision of the script, I happened qe leaving net
config workstation like the following can cause problems.

Nombre del equipo \\WINDOWSVERSION
Nombre completo de equipo windowsversion nt
Nombre de usuario windowsversi

Estaci¢n de trabajo activa en
NetbiosSmb (000000000000)

Versi¢n del programa Windows Vista (TM)
Starter

Dominio de estaci¢n de trabajo WORKGROUP
Dominio de inicio de sesi¢n WINDOWSVERS

Tiempo de espera de COM (s) 0
Cuenta de env¡o de COM (bytes) 16
Tiempo de env¡o en COM (ms.) 250
Se ha completado el comando correctamente.

The review is finished, publish the when tested in windows seven.

Frank P. Westlake

unread,
Mar 9, 2009, 9:26:08 PM3/9/09
to
This part is wrong:

> Processor(s): 1 Processor(s) Installed.
> [01]: x86 Family 6 Model 28 Stepping 2

According to MSINFO.EXE, which is correct:

Intel(R) Atom(TM) Z520 @ 1.33 GHz, 1333 MHz 1Core(s), 2 Logical
Processor(s)

And the environment:
NUMBER_OF_PROCESSORS=2
PROCESSOR_IDENTIFIER=x86 Family 6 Model 28 Stepping 2, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=1c02

I don't know if it is a bug in SYSTEMINFO, me misinterpreting something, or
a misconfiguration in the system.

Frank

0x0...@gmail.com

unread,
Mar 10, 2009, 1:44:05 AM3/10/09
to

I leave here the corrected version now also works if the workstation
service is stopped. (net stop workstation).

http://sites.google.com/site/ntbatchsite/universal-batch-operating-system-detector

Greetings.

Timo Salmi

unread,
Mar 10, 2009, 5:01:08 AM3/10/09
to
Frank P. Westlake <frank.w...@yahoo.net> wrote:
> I don't recall seeing %SystemRoot%\System32\SYSTEMINFO.EXE in any
> previous versions so I'll take the chance that it's new in Vista and
> present it to those of you who don't have Vista but need to be prepared
> for it.

My XP SP3 seems to have it it.

Dr J R Stockton

unread,
Mar 10, 2009, 11:07:21 AM3/10/09
to
In alt.msdos.batch.nt message <gp3sol$du8$1...@news.albasani.net>, Mon, 9
Mar 2009 13:03:48, Frank P. Westlake <frank.w...@yahoo.net> posted:

>I don't recall seeing %SystemRoot%\System32\SYSTEMINFO.EXE in any
>previous versions so I'll take the chance that it's new in Vista and
>present it to those of you who don't have Vista but need to be prepared
>for it.

My XP pro sp3 has it, with no obvious differences in what it does.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.

Frank P. Westlake

unread,
Mar 10, 2009, 3:35:11 PM3/10/09
to
"Dr J R Stockton"
news:dbVJgAHp...@invalid.uk.co.demon.merlyn.invalid...

> My XP pro sp3 has it, with no obvious differences in what it does.

I frequently post articles then do the research I should have done to see it
they should not have been posted. After I sent that message I searched this
group and found that Ted Davis had written about it two years ago in this
group, and others since who also had Windows XP.

My apologies to all for littering the group.

Frank

0x0...@gmail.com

unread,
Mar 10, 2009, 7:02:27 PM3/10/09
to
I test the script:
http://sites.google.com/site/ntbatchsite/universal-batch-operating-system-detector
(version 10-3-2009 v0.9)

and runs on Windows 7. I'm happy because the script was very good.

As if anyone needs to know the exits to ver and net config workstation
in Windows 7, these are:

ver:
Microsoft Windows [Version 6.1.7048]


net.exe config workstation:
...
Software version Windows 7 Ultimate
...

Timo Salmi

unread,
Mar 10, 2009, 7:44:44 PM3/10/09
to
0x0...@gmail.com wrote:
> As if anyone needs to know the exits to ver and net config workstation
> in Windows 7, these are:
>
> ver:
> Microsoft Windows [Version 6.1.7048]
>
>
> net.exe config workstation:
> ...
> Software version Windows 7 Ultimate
> ...

What is the value of %OS% then?

0x0...@gmail.com

unread,
Mar 10, 2009, 7:59:01 PM3/10/09
to
OS=Windows_NT

0x0...@gmail.com

unread,
Mar 11, 2009, 12:24:47 AM3/11/09
to
I updated the script slightly, because Windows x64 2003 version uses
kernel 5.2 like windows server 2003
The current version is: 11-3-2009 v1.1

DL

unread,
Mar 11, 2009, 10:43:54 AM3/11/09
to
On Mar 7, 2:31 pm, 0...@0.0 (FileGod) wrote:
> Matthias Tacke <Matth...@Tacke.de> wrote:
> >Thomas Steinbach wrote:
> > Hello NG,
>
> > how can I determine in a Batch-Scipt which OS
> > is running? What technics do you use and prefer?
> > Win 2000 or OS prior to Win 2000, Win XP
> > or Win Vista and Win7
>
> Sorry, I missed the original question but this batch file I found a few
> months ago might help you...
>
> @ECHO OFF
>
> :: Win9x checks ::::::::::::
>
> VER |find /i "Windows 95" >NUL
> IF NOT ERRORLEVEL 1 GOTO W9598ME
>
> VER |find /i "Windows 98" >NUL
> IF NOT ERRORLEVEL 1 GOTO W9598ME
>
> VER |find /i "Windows Millennium" >NUL
> IF NOT ERRORLEVEL 1 GOTO W9598ME
>
> :: NT/XP checks ::::::::::::
> VER | find "XP" > nul
> IF %errorlevel% EQU 0 GOTO s_win_XP
>
> VER | find "2000" > nul
> IF %errorlevel% EQU 0 GOTO s_win_2000
>
> VER | find "NT" > nul
> IF %errorlevel% EQU 0 GOTO s_win_NT
>
> ECHO Unknown OS !
> GOTO :EOF
>
> :: Win9x commands ::::::::::::
>
> :W9598ME
> ECHO Win9x commands go here
> GOTO :EOF
>
> :W98
> ECHO Win98 commands go here
> GOTO :EOF
>
> :: NT/XP commands ::::::::::::
>
> :s_win_XP
> ECHO XP commands go here
> goto :eof
>
> :s_win_2000
> ECHO WIN2K commands go here
> goto :eof
>
> :s_win_NT
> ECHO NT4 commands go here
> goto :eof
>
> :EOF (End-of-file)Service Pack Version
>
> I found this here:http://www.fortypoundhead.com/showcontent.asp?ArtID=837
>  I am sorry it does not cover DOS.http://www.filegod.netfirms.com

How about Vista? I don't have one to test it out.

Herbert Kleebauer

unread,
Mar 11, 2009, 10:58:27 AM3/11/09
to
DL wrote:
> On Mar 7, 2:31 pm, 0...@0.0 (FileGod) wrote:
> > Matthias Tacke <Matth...@Tacke.de> wrote:
> > >Thomas Steinbach wrote:
> > > Hello NG,
> >
> > > how can I determine in a Batch-Scipt which OS
> > > is running? What technics do you use and prefer?
> > > Win 2000 or OS prior to Win 2000, Win XP
> > > or Win Vista and Win7

You also can do this with a batch embedded exe (again, only
in 32 bit Windows, in 64 bit Windows you have to copy the
exe to your system). This code will also run in plain
DOS.

@echo off
echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>gver.com
echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>gver.com
echo wvPp0w@h3k9C5/R/pN0d0uDh37bwo1YioGEWtbGov5//B6mkuMEo0IL0l/w>>gver.com
echo ef2iC57R/pNEA/jeefHhC5AR/pNEA/juefXgC5ER/phCfDM@m042knfuurC>>gver.com
echo l4Ncl5Bd4k03E53YlzzT0k0gF0/hl70QV2TE@AB61WWPqjvY0u31/WEXyT/>>gver.com
echo U7ycf6/uS1/oaEnVUP/ApQ7nJ5RUMLNmxJPVdqPmp2Ak/2Ak/2AkoU1nJ5R>>gver.com
echo UMLNmxJPdtqPmp2Ak/2Ak/2AkoU1nJ5RUMLNmxZMpZ5PYp2Ak/2Ak/2AkoU>>gver.com
echo 1nJ5RUMLNmx4Qg45RapXNaNaNaNaNapU1nJ5RUMLNmxpMnFKDUEGi1/EkUX>>gver.com
echo /A/6Ak3Em23/t8I/o8A/1W4QYsgDslKAw5A/JFLkI/0//ItJeBPQ/s/wE/@>>gver.com
echo 3E0A//0PYUpEY03N/W5/R03N7k43gV03gl0UY00PIk/PE/3L/V5EQ03PI/3>>gver.com
echo Pc/6EQ0DPA43Lkl5Os1RZV6RN/f/N/F53Y00Po/7L/y5zjlrg0l54k83Lc9>>gver.com
echo 3Lc@3LMA3PI/NEgF1M0F5EQ0WEgF1u0l47/l5JIpI48pAms1Nglq4g0l56o>>gver.com
echo INnBLMbJaEjVLE/gIFGtIFABXAiE5PgR0bEQVeEQViEQVlEgl04VLOo0ZQj>>gver.com
echo BKNnBL56J5RHF6N74aPYlKNOQZQdFLN5Z5PZZlFZFbJZ8rQdxaP4VLE/U56>>gver.com
echo G/3/zL04E/3/yOF3/0kjU70E/o@0NUCdNgs02SA0c2K5BJbvc@N58uDu@aV>>gver.com
echo O/wT47/0E/ALNo0WRZ8rLh4aOj8LD/ALNo0WRZ8rLhZaPj8LD/ALNo0WRZ8>>gver.com
echo rLWJLOgFKD/ALNo0WRZ8rLklKMoNKD/ALNo0WRZ8rLXB6Nx/UJtWE5yuM3/>>gver.com
echo 0Ek/H/W12csD/cy8Mr//9w8/9AA7OVFWXijC50E/US2NspkPQE29/UW5M31>>gver.com
echo /Hr0cDE5f@zkWOU3/0EA/DE0I70E/IL2eJzzJk/3/0kcI70E/c5/cVV3/0U>>gver.com
echo O0Ua0G/3/ExT4E/0E/Y/kplVO/Uq0G/3/cRU3/0UO/wT4//0E/c5/zL01E/>>gver.com
echo 3/0q25G/3/0YFRMDA/r8LOoJ57Z8bQj8r58Et5zjVs.>>gver.com

gver.com>gver.exe
gver.exe>gver.bat
call gver.bat
for %%i in (com exe bat) do del gver.%%i

echo PlatformId=%ver_platf%
echo MajorVersion=%ver_major%
echo MinorVersion=%ver_minor%
echo BuildNumber=%ver_build%
echo CSDVersion=%ver_csd%


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
For DOS:

dwPlatformId=ffffffff


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
FOR Windows:


dwMajorVersion
--------------
Major version number of the operating system. This member can be one of
the following values.

Operating System Meaning
Windows 95 4
Windows 98 4
Windows Me 4
Windows NT 3.51 3
Windows NT 4.0 4
Windows 2000 5
Windows XP 5
Windows Server 2003 family 5

dwMinorVersion
--------------
Minor version number of the operating system. This member can be one of
the following values.

Operating System Meaning
Windows 95 0
Windows 98 10
Windows Me 90
Windows NT 3.51 51
Windows NT 4.0 0
Windows 2000 0
Windows XP 1
Windows Server 2003 family 2


dwBuildNumber
-------------
Build number of the operating system.

Windows Me/98/95: The low-order word contains the build number of the
operating system. The high-order word contains the major
and minor version numbers.

dwPlatformId
------------
Operating system platform. This member can be one of the following values.

Value Meaning
0 VER_PLATFORM_WIN32s Win32s on Windows 3.1.
1 VER_PLATFORM_WIN32_WINDOWS Windows 95, Windows 98, or Windows Me.
2 VER_PLATFORM_WIN32_NT Windows NT, Windows 2000, Windows XP,
or Windows Server 2003 family.

szCSDVersion
------------
Pointer to a null-terminated string, such as "Service Pack 3", that
indicates the latest Service Pack installed on the system. If no Service
Pack has been installed, the string is empty.

Windows Me/98/95: Pointer to a null-terminated string that indicates
additional version information. For example, " C"
indicates Windows 95 OSR2 and " A" indicates Windows 98
Second Edition.


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


The source code:

dosmain:move.w s6,-(sp)
move.w (sp)+,s0
move.b #$30,m0
trap #$21
move.b m0,r1
move.l #_text+20,r6
bsr.w bin2hex
move.b r1,r0
bsr.w bin2hex
move.b m3,r0
bsr.w bin2hex

move.w #_text,r1
move.b #$09,m0
trap #$21
move.w #$4c01,r0
trap #$21

_text: dc.b "set ver_major=00000000",$0d,$0a
dc.b "set ver_minor=00000000",$0d,$0a
dc.b "set ver_build=00000000",$0d,$0a
dc.b "set ver_platf=ffffffff",$0d,$0a
dc.b "set ver_csd= ",'$'

bin2hex:move.w #2,r2
lsl.w #8,r0
_10: eor.b r0,r0
rol.w #4,r0
and.b #$0f,r0
add.b #$90,r0
adj_dec_add r0
addc.b #$40,r0
adj_dec_add r0
or.b #$20,r0
move.b r0,(r6.w)
inc.w r6
dbf.w r2,_10
addq.w #22,r6
rts.w

winmain::
move.l #VersionInfo,-(sp)
jsr.l (GetVersionExA)

move.l #text1,r5
move.l #VersionInfo+4,r6

move.l #4,r4
_10: bsr.l putstring
move.l (r6),r0
addq.l #4,r6
bsr.l hexout_r0
dec.l r4
bne.b _10
bsr.l putstring
move.l r6,r5
bsr.l putstring

moveq.l #0,-(sp)
jsr.l (ExitProcess) ; exit program

text1: dc.b "set ver_major=",0
text2: dc.b "set ver_minor=",0
text3: dc.b "set ver_build=",0
text4: dc.b "set ver_platf=",0
text5: dc.b "set ver_csd=",0

hexout_r0:
move.l r5,-(sp)
move.l #8,r2
move.l #_buf,r5
_20: rol.l #4,r0
move.b r0,r1
and.b #$0f,r1
cmp.b #9,r1
bls.b _10
add.b #'a'-10-'0',r1
_10: add.b #'0',r1
move.b r1,(r5)
inc.l r5
dbf.l r2,_20

move.l #_buf,r5
bsr.l putstring
move.l (sp)+,r5
rts.l
_buf: blk.b 8,0
dc.b $0d,$0a,0

putstring:
_20: move.b (r5),r0
inc.l r5
or.b r0,r0
beq.b _10
bsr.l putc
br.b _20
_10: rts.l

putc: move.b r0,_buf
eor.l r0,r0
add.l _handle,r0
bne.b _10
moveq.l #-11,-(sp)
jsr.l (GetStdHandle)
move.l r0,_handle
_10: moveq.l #0,-(sp)
move.l #_count,-(sp)
moveq.l #1,-(sp)
move.l #_buf,-(sp)
move.l r0,-(sp)
jsr.l (WriteFile)
or.l r0,r0
bne.b _20
_30: moveq.l #0,-(sp)
move.l #_text,-(sp)
move.l #_text,-(sp)
moveq.l #0,-(sp)
jsr.l (MessageBoxA)
moveq.l #0,-(sp)
jsr.l (ExitProcess)
_20: cmp.l #1,_count
bne.b _30
rts.l

_buf: dc.b 0
_text: dc.b 'write error',0
even4
_handle:dc.l 0
_count: dc.l 0

VersionInfo:
dc.l 148
blk.l 4
blk.b 128

0x0...@gmail.com

unread,
Mar 11, 2009, 11:06:18 PM3/11/09
to
I liked this application. gver.exe
Enough information delivery.

Oswald Low

unread,
Mar 13, 2009, 5:32:56 AM3/13/09
to
On Wed, 11 Mar 2009 14:58:27 -0000, Herbert Kleebauer <kl...@unibwm.de>
wrote:

> DL wrote:
>> On Mar 7, 2:31 pm, 0...@0.0 (FileGod) wrote:
>> > Matthias Tacke <Matth...@Tacke.de> wrote:
>> > >Thomas Steinbach wrote:
>> > > Hello NG,
>> >
>> > > how can I determine in a Batch-Scipt which OS
>> > > is running? What technics do you use and prefer?
>> > > Win 2000 or OS prior to Win 2000, Win XP
>> > > or Win Vista and Win7
>
> You also can do this with a batch embedded exe (again, only
> in 32 bit Windows, in 64 bit Windows you have to copy the
> exe to your system). This code will also run in plain
> DOS.

I appended this to your code:


echo Family:
if %ver_platf%==ffffffff echo DOS
if %ver_platf%==00000000 echo W3.1
if %ver_platf%==00000001 echo W9x/ME
if %ver_platf%==00000002 echo NT/XP/Vista
echo OS:
if %ver_major%==00000003 if %ver_minor%==00000051 echo NT3.51
if %ver_major%==00000004 if %ver_minor%==00000000 echo W95
if %ver_major%==00000004 if %ver_minor%==00000010 echo W98
if %ver_major%==00000004 if %ver_minor%==00000090 echo ME
if %ver_major%==00000004 if %ver_minor%==00000000 echo NT4.0
if %ver_major%==00000005 if %ver_minor%==00000000 echo W2k
if %ver_major%==00000005 if %ver_minor%==00000001 echo XP
if %ver_major%==00000005 if %ver_minor%==00000002 echo WSrv2k3


--
Lovely plumage

Message has been deleted

ten.n...@virgin.net

unread,
Mar 15, 2009, 8:34:11 AM3/15/09
to

I was informed a couple of years or so ago, that the following is not
language independent:
NET.EXE CONFIG WORKSTATION
The following however was more suitable working solution:
NET CONFIG WORK

As a side note, I didn't realise that you were part of the official
Microsoft Beta testing team; Version 6.1.7000 was the Public Beta, so
you're not using an illegal version are you?

FileGod

unread,
Mar 16, 2009, 1:25:18 PM3/16/09
to
carlos <cmon...@gmail.com> wrote:
>You can detect if operating system is 64 bits, checking if not exist
>ntvdm.dll

>if exist %windir%\system32\ntvdm.dll (set bits=32) else (set bits=64)


Carlos, it seems backwards, I do not have ntvdm.dll or XP 64 bits, other
than that your batch file works fine, here it is the way I changed it:

@echo off
if exist %windir%\system32\ntvdm.dll (set bits=64) else (set bits=32)
echo %bits%

http://www.filegod.netfirms.com

Zaphod Beeblebrox

unread,
Mar 16, 2009, 3:15:15 PM3/16/09
to

"FileGod" <0@0.0> wrote in message
news:2Yvvl.9689$%54....@nlpi070.nbdc.sbc.com...

For carlos' check to work, it appears that it should be looking for
ntvdm.exe or perhaps ntvdmd.dll, both of which exist in
%windir%\system32 on my XP 32-bit system. I don't have a 64-bit
system handy to check.

--
Zaphod

Pan-Galactic Gargle Blaster: A cocktail based on Janx Spirit.
The effect of one is like having your brain smashed out
by a slice of lemon wrapped round a large gold brick.


0 new messages