Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 417 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detect whether current Windows version is 32 bit or 64 bit

#1
Believe it or not, my installer is so old that it doesn't have an option to detect the 64-bit version of Windows.

Is there a Windows DLL call or (even better) an environment variable that would give that information for Windows XP and Windows Vista?

**One possible solution**

I see that Wikipedia states that the 64-bit version of Windows XP and Windows Vista have a unique environment variable: `%ProgramW6432%`, so I'm guessing that'd be empty on 32-bit Windows.

This variable points to `Program Files` directory, which stores all the installed program of Windows and others. The default on English-language systems is `C:\Program Files`. In 64-bit editions of Windows (XP, 2003, Vista), there are also `%ProgramFiles(x86)%` which defaults to `C:\Program Files (x86)` and `%ProgramW6432%` which defaults to `C:\Program Files`. The `%ProgramFiles%` itself depends on whether the process requesting the environment variable is itself 32-bit or 64-bit (this is caused by Windows-on-Windows 64-bit redirection).
Reply

#2
If you can make API calls, try using [GetProcAddress][1] / [GetModuleHandle][2] to check for the existence of [IsWow64Process][3] which is only present in Windows OS that have 64-bit versions.

You could also try the **ProgramFiles(x86)** environment variable used in Vista/2008 for backwards compatibility, but I'm not 100% sure about XP-64 or 2003-64.

Good luck!

[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply

#3
I tested the solution I suggested in my question:

Tested for Windows Environment Variable: ProgramW6432

If it's non empty then it's 64 bit Windows.W
Reply

#4
For a VBScript / WMI one-liner that retrieves the actuals bits number (32 or 64) of the OS or the Hardware, take a look at [

[To see links please register here]

][1]


[1]:

[To see links please register here]

Reply

#5
I know this is ancient but, here's what I use to detect Win764

On Error Resume Next

Set objWSHShell = CreateObject("WScript.Shell")

strWinVer = objWSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\BuildLabEx")

If len(strWinVer) > 0 Then
arrWinVer = Split(strWinVer,".")
strWinVer = arrWinVer(2)
End If

Select Case strWinVer
Case "x86fre"
strWinVer = "Win7"
Case "amd64fre"
strWinVer = "Win7 64-bit"
Case Else
objWSHShell.Popup("OS Not Recognized")
WScript.Quit
End Select
Reply

#6
I want to add what I use in shell scripts (but can easily be used in any language) here.
The reason is, that some of the solutions here don't work an WoW64, some use things not really meant for that (checking if there is a *(x86) folder) or don't work in cmd scripts.
I feel, this is the "proper" way to do it, and should be safe even in future versions of Windows.


@echo off
if /i %processor_architecture%==AMD64 GOTO AMD64
if /i %PROCESSOR_ARCHITEW6432%==AMD64 GOTO AMD64
rem only defined in WoW64 processes
if /i %processor_architecture%==x86 GOTO x86
GOTO ERR
:AMD64
rem do amd64 stuff
GOTO EXEC
:x86
rem do x86 stuff
GOTO EXEC
:EXEC
rem do arch independent stuff
GOTO END
:ERR
rem I feel there should always be a proper error-path!
@echo Unsupported architecture!
pause
:END
Reply

#7
Check the Registry for the existence of HKLM\SOFTWARE\Wow6432Node
- If it's there, the system is 64-bit
- 32-bit, otherwise.
Reply

#8
I don't know what language you're using, but [.NET][1] has the environment variable `PROCESSOR_ARCHITEW6432` if the OS is 64-bit.

If all you want to know is whether your application is running 32-bit or 64-bit, you can check `IntPtr.Size`. It will be 4 if running in 32-bit mode and 8 if running in 64-bit mode.

[1]:

[To see links please register here]

Reply

#9
To check for a 64-bit version of Windows in a command box, I use the following template:

test.bat:

@echo off
if defined ProgramFiles(x86) (
@echo yes
@echo Some 64-bit work
) else (
@echo no
@echo Some 32-bit work
)

`ProgramFiles(x86)` is an environment variable automatically defined by cmd.exe (both 32-bit and 64-bit versions) on Windows 64-bit machines only.
Reply

#10
I don't know on which Windows version it exists, but on Windows Vista and later this runs:

Function Is64Bit As Boolean
Dim x64 As Boolean = System.Environment.Is64BitOperatingSystem
If x64 Then
Return true
Else
Return false
End If
End Function
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through