#185841 - 2008-02-29 08:08 PM
Is my Windows 64 bit or 32 bit or other?
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
I want to write a script that finds if my Windows is 64 bit or 32 bit (or another taste) to decide which installation package should be used.
Has anybody a better suggestion then trying to find an environment variable like ProgramFiles(x86) or CommonProgramFilesx(86)?
Break On
;Declare variables
Dim $CommonProgramFiles
Dim $CommonProgramFilesx86
Dim $ProgramFiles
Dim $ProgramFilesx86
;Code
$ProgramFilesx86 = '%ProgramFiles(x86)%'
If Not $ProgramFilesx86 = ''
? '64 bit OS'
Else
? 'Not 64 bit OS'
$ProgramFiles = '%ProgramFiles%'
If Not $ProgramFiles = ''
? '32 bit OS'
EndIf
EndIf
$CommonProgramFilesx86 = '%CommonProgramFilesx(86)%'
If Not $CommonProgramFilesx86 = ''
? '64 bit OS'
Else
? 'Not 64 bit OS'
$CommonProgramFiles = '%CommonProgramFiles%'
If Not $CommonProgramFiles = ''
? '32 bit OS'
EndIf
EndIf
|
|
Top
|
|
|
|
#185856 - 2008-03-01 05:17 AM
Re: Is my Windows 64 bit or 32 bit or other?
[Re: Glenn Barnas]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
Thanks Glenn. HOWTO: Detect Process Bitness What about this to start?
; =========================================================================================== ; ; Script Information ; ; Title: WinNT32or64 ; Author: Wim Rotty ; Description: Find if Windows is 32 or 64 bit ; ; ; =========================================================================================== ;Script Options If Not @LOGONMODE Break On Else Break Off EndIf Dim $RC $RC = SetOption("Explicit", "On") $RC = SetOption("NoMacrosInStrings", "On") $RC = SetOption("NoVarsInStrings", "On") If @SCRIPTEXE = "KIX32.EXE" $RC = SetOption("WrapAtEOL", "On") EndIf
;Declare variables Dim $OS Dim $PROCESSOR_ARCHITECTURE Dim $PROCESSOR_ARCHITEW6432 Dim $bit
;Initialize variables $OS = '%OS%' $PROCESSOR_ARCHITECTURE = '%PROCESSOR_ARCHITECTURE%' $PROCESSOR_ARCHITEW6432 = '%PROCESSOR_ARCHITEW6432%'
;Code Select Case Not $OS = 'Windows_NT' Exit 1150 Case $PROCESSOR_ARCHITECTURE = 'amd64' Or $PROCESSOR_ARCHITEW6432 = 'amd64' $bit = '64' Case $PROCESSOR_ARCHITECTURE = 'x86' And $PROCESSOR_ARCHITEW6432 = '' $bit = '32' Case 1 Exit 1150 EndSelect
? $bit |
|
|
Top
|
|
|
|
#185858 - 2008-03-01 10:09 PM
Re: Is my Windows 64 bit or 32 bit or other?
[Re: Witto]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
|
Well, if you really want to reverse-golf it, it's a start. 
$Bits = IIf(InStr('%PROCESSOR_ARCHITECTURE% %PROCESSOR_ARCHITEW6432%', 'AMD64'), 64, 32)
'Bits: ' $Bits ?
brings the core code for local system detection to one line. It's so small and simple I haven't even bothered with a UDF, especially since when I need this, I need to know remotely, and the WMISysInfo UDF supplies the HW/OS info I need.
If you read the article, it basically says that if either of the Env Vars contain "AMD64", you are running on a 64 bit OS. The only alternative (for Kix, at least) is 32 bit x86. The logic above tests both vars for AMD64 in one pass. If you need to further determine if you're in a WOW64 session, you can read the %PROCESSOR_ARCHITEW6432% value directly.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#198509 - 2010-04-29 08:24 PM
Re: Is my Windows 64 bit or 32 bit or other?
[Re: Lonkero]
|
MattColeman
Fresh Scripter
Registered: 2008-05-19
Posts: 12
Loc: Kitchener-Waterloo, ON
|
thanks for the @ONWOW64 heads up lonkero... works like a charm!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 735 anonymous users online.
|
|
|