Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

64-BIT OS: PROCESSOR_ARCHITECTURE=x86

Status
Not open for further replies.

woter324

Technical User
Jan 26, 2007
179
GB
Hi there,

Riddle me this:

I have a piece of code that pulls the environment variable PROCESSOR_ARCHITECTURE. The system is (Windows 7) 64-bit but my code thinks it is a 32-bit system. What gives??

The code in VBScript:
Code:
Set wshShell = CreateObject("WScript.Shell")

strProcessorArchitecture = wshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")

wscript.echo strProcessorArchitecture

Returns: x86.

From a command prompt, if I run:
Code:
echo %PROCESSOR_ARCHITECTURE%
Returns: AMD64

If I look in Windows environment variables, I see AMD64.

The only thing I can think of is the OS is running as a VM on ESX 3.5. I have tried the code on a 64-bit physical machine and it returns AMD64.

Before I go off to VMWare forums, I was wondering if anyone here may have seen similar behaviour before. It is only the VBScript code that lies.

Maybe I can find a WMI query to do the same thing.

Any ideas / help would be greatly apreciated.

Many thanks
 
Interestingly, I have just run the following WMI query:

Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colItems
	MsgBox "Architecture: " & objItem.Architecture
Next

This returns: Architecture: 9

According to MSDN , 9 is x64.

So WMI and 'DOS' sees it as the correct Architecture, but for some reason WScript.Shell (VBScript) doesn't.

Oh well, I can use WMI as a replacement. Just anoying! lol

Thanks
 
i would suggest you are seeing this 'expected' result (because it is expected) because your vbscript is infact running under a 32bit context?

if you open up %windir%\syswow64\cmd.exe and type the set command you will get your x86

if you open up %windir%\cmd.exe and type the set command you will get your amd64

so, my question would be what process is starting your cscript.exe or wscript.exe, i would guess that is running under a 32 bit context....something like an SCCM client?

the WMI 'works' because it doesnt really have a 32 bit context
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top