How to find the 32 & 64 bit OS type in a cmd file

B

BrianB

I'm modifying a cmd script and need to know which type of Windows it's
running and if it is 32 or 64 bit. I've found several sites suggesting that
the ver command works to find the OS, but the suggestions do not cover all
version of XP and Vista. By trial and error I have ...

ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
ver | find "Microsoft Windows [Version 6.0" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "Microsoft Windows [Version 5.2" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto error

But I cannot find any definitive list of what ver returns for each OS. For
64-bit XP the ver output does not include the string "XP".

I haven't a clue how to determine if its a 32-bit or 64-bit OS.

Any suggestions?
Brian Bygland
 
B

Big_Al

BrianB said:
I'm modifying a cmd script and need to know which type of Windows it's
running and if it is 32 or 64 bit. I've found several sites suggesting that
the ver command works to find the OS, but the suggestions do not cover all
version of XP and Vista. By trial and error I have ...

ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
ver | find "Microsoft Windows [Version 6.0" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "Microsoft Windows [Version 5.2" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto error

But I cannot find any definitive list of what ver returns for each OS. For
64-bit XP the ver output does not include the string "XP".

I haven't a clue how to determine if its a 32-bit or 64-bit OS.

Any suggestions?
Brian Bygland
How about PROCESSOR_ARCHITECTURE=x86
 
B

BrianB

Big_Al said:
BrianB said:
I'm modifying a cmd script and need to know which type of Windows it's
running and if it is 32 or 64 bit. I've found several sites suggesting
that the ver command works to find the OS, but the suggestions do not
cover all version of XP and Vista. By trial and error I have ...

ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
ver | find "Microsoft Windows [Version 6.0" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "Microsoft Windows [Version 5.2" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto error

But I cannot find any definitive list of what ver returns for each OS.
For 64-bit XP the ver output does not include the string "XP".

I haven't a clue how to determine if its a 32-bit or 64-bit OS.

Any suggestions?
Brian Bygland
How about PROCESSOR_ARCHITECTURE=x86

Thank you. That covers the bit value. Now I just need the OS.
 
B

Big_Al

BrianB said:
Big_Al said:
BrianB said:
I'm modifying a cmd script and need to know which type of Windows it's
running and if it is 32 or 64 bit. I've found several sites suggesting
that the ver command works to find the OS, but the suggestions do not
cover all version of XP and Vista. By trial and error I have ...

ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
ver | find "Microsoft Windows [Version 6.0" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "Microsoft Windows [Version 5.2" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto error

But I cannot find any definitive list of what ver returns for each OS.
For 64-bit XP the ver output does not include the string "XP".

I haven't a clue how to determine if its a 32-bit or 64-bit OS.

Any suggestions?
Brian Bygland
How about PROCESSOR_ARCHITECTURE=x86

Thank you. That covers the bit value. Now I just need the OS.
On a command line just type 'set'
It will return all the variables.
 
B

BrianB

Big_Al said:
BrianB said:
Big_Al said:
BrianB wrote:
I'm modifying a cmd script and need to know which type of Windows it's
running and if it is 32 or 64 bit. I've found several sites suggesting
that the ver command works to find the OS, but the suggestions do not
cover all version of XP and Vista. By trial and error I have ...

ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
ver | find "Microsoft Windows [Version 6.0" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "Microsoft Windows [Version 5.2" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto error

But I cannot find any definitive list of what ver returns for each OS.
For 64-bit XP the ver output does not include the string "XP".

I haven't a clue how to determine if its a 32-bit or 64-bit OS.

Any suggestions?
Brian Bygland
How about PROCESSOR_ARCHITECTURE=x86

Thank you. That covers the bit value. Now I just need the OS.
On a command line just type 'set'
It will return all the variables.

None of the variables tell me if its XP or Vista or W2k or ...
 
B

BrianB

Cool. That gives me what I need to know. One last question. Any suggestion
how to get the information from VBS back to the cmd script?

Brian

John John (MVP) said:
Use WMI and Win32_OperatingSystem class.

http://www.microsoft.com/technet/scriptcenter/topics/ccs/ccs_predeploy1.mspx

John
I'm modifying a cmd script and need to know which type of Windows it's
running and if it is 32 or 64 bit. I've found several sites suggesting
that the ver command works to find the OS, but the suggestions do not
cover all version of XP and Vista. By trial and error I have ...

ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
ver | find "Microsoft Windows [Version 6.0" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "Microsoft Windows [Version 5.2" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto error

But I cannot find any definitive list of what ver returns for each OS.
For 64-bit XP the ver output does not include the string "XP".

I haven't a clue how to determine if its a 32-bit or 64-bit OS.

Any suggestions?
Brian Bygland
 
J

John John (MVP)

You might want to ask the folks in one of the scripting groups or one of
the script pros reading here might want to offer additional help.

John
Cool. That gives me what I need to know. One last question. Any suggestion
how to get the information from VBS back to the cmd script?

Brian

Use WMI and Win32_OperatingSystem class.

http://www.microsoft.com/technet/scriptcenter/topics/ccs/ccs_predeploy1.mspx

John
I'm modifying a cmd script and need to know which type of Windows it's
running and if it is 32 or 64 bit. I've found several sites suggesting
that the ver command works to find the OS, but the suggestions do not
cover all version of XP and Vista. By trial and error I have ...

ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
ver | find "Microsoft Windows [Version 6.0" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "Microsoft Windows [Version 5.2" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto error

But I cannot find any definitive list of what ver returns for each OS.
For 64-bit XP the ver output does not include the string "XP".

I haven't a clue how to determine if its a 32-bit or 64-bit OS.

Any suggestions?
Brian Bygland
 
B

BrianB

Thank you. I'll try the scripting.vbscript group.

Brian

John John (MVP) said:
You might want to ask the folks in one of the scripting groups or one of
the script pros reading here might want to offer additional help.

John
Cool. That gives me what I need to know. One last question. Any
suggestion how to get the information from VBS back to the cmd script?

Brian

Use WMI and Win32_OperatingSystem class.

http://www.microsoft.com/technet/scriptcenter/topics/ccs/ccs_predeploy1.mspx

John

BrianB wrote:

I'm modifying a cmd script and need to know which type of Windows it's
running and if it is 32 or 64 bit. I've found several sites suggesting
that the ver command works to find the OS, but the suggestions do not
cover all version of XP and Vista. By trial and error I have ...

ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003
ver | find "Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista
ver | find "Microsoft Windows [Version 6.0" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "Microsoft Windows [Version 5.2" > nul
if %ERRORLEVEL% == 0 goto ver_xp
ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000
ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt
echo Machine undetermined.
goto error

But I cannot find any definitive list of what ver returns for each OS.
For 64-bit XP the ver output does not include the string "XP".

I haven't a clue how to determine if its a 32-bit or 64-bit OS.

Any suggestions?
Brian Bygland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top