HTA vs Vbs

In VBS this code tells you what bit version of windows is installed on the machine (32 vs 64 bit)
Set oShell = CreateObject("WScript.Shell")
WindowsProcessorArchitecture = oShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")

But in HTA this excact same code gives the wrong vaule!? If I run the code in a vbs file is gives me x86 on a 32 bit and AMD64 on a 64 bit windows.
But in HTA it gives me x86 on all version of windows. Is there another way to read Environment Strings in HTA?
Regard Brian
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think what's happening is the script is running in the 32bit environment.  oShell.ExpandEnvironmentStrings is probably returning the value from the "Process" environment.

Try the "System" environment:
Set oShell = CreateObject("WScript.Shell")
Set colEnvSystem = oShell.Environment("System")
WindowsProcessorArchitecture = colEnvSystem("PROCESSOR_ARCHITECTURE")

I have not tested this...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Just tested, and it returns AMD64 for me using System and x86 using Process
Brian_LarsenAuthor Commented:
Hey jostrander

I think you are right. I am reading about WOW64 as we speak. I will test your code and let you know ASAP.
But that will mean that HTA runs in a 32 bit enviroment and vbs dosen't? Anyway I also stumbleupon this site i my quest for answers wich explains it pretty well:

And there is some confusion about if this code will give the same result as well:
Get-WmiObject -class "Win32_Processor" -property "AddressWidth"
If the AddressWidth is "32" then you're on a 32-bit operating system. If the AddressWidth is "64" then you're on a 64-bit operating system. Some says it dos other that it dosen't. I can't really find any information from microsoft to verify this.

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Brian_LarsenAuthor Commented:
Ohh you replied while I was writing my comment. Well it sounds promising then. Will test it tomorrow at work, don't have a 64 bit computer at home. Thanks
Not sure, but I think you can change the environment that the HTA runs in... it's basically Internet Explorer, so I think if you set IE 64 bit as the default, it would change that.  I wouldn't recommend that though.
Brian_LarsenAuthor Commented:
Hey Jostrander

Just tested your code and it works as expected.
I also found out that you can test for the variable %PROCESSOR_ARCHITEW6432%. So if you run a 32 bit process in wow64 mode, then it creates an Environment Variable called PROCESSOR_ARCHITEW6432 in the "Process" (not "System").

Thanks for taking the time to help me out and put me in the right direction, really appreciate it.
Regards Brian
Brian_LarsenAuthor Commented:
spot on
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.