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
With the VER command. Use FOR /F to get the output text.
Frank
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/
> Find Timo Salmi's FAQ posting.
>
> Tom Lavedas
To save you looking for it:
http://www.netikka.net/tsneti/info/tscmd004.htm
--
Regards
Matthias
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
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
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::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::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::::::::::::::::::::::::::::::::::::::::::::::::::
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).
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.
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
::::::::::::::::::::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
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)
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.
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/
> 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
--
Lovely plumage
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.
> 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
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
I've added a link to your posting, into my item #4.
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.
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
> 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
**********************************************************************
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
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.
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
http://sites.google.com/site/ntbatchsite/universal-batch-operating-system-detector
Greetings.
My XP SP3 seems to have it 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.
> 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
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
...
What is the value of %OS% then?
How about Vista? I don't have one to test it out.
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
> 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
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?
>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%
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.