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

  • Thread starter Thread starter BrianB
  • Start date Start date
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
 
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
 
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.
 
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.
 
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 ...
 
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
 
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
 
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
 
Back
Top