Jump to content

Adding getArch() function to WPI


Recommended Posts

Hi, I am looking into adding a "getArch()" function so I get retrieve the CPU architecture (x86 or AMD64).

Where is the best place to add the code for this?

I was thinking in API.JS, just after "getOSver()".

Something like:

function getArch()
{
position="api.js";
whatfunc="getArch()";

var arch="";

try
{
arch = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%");
}
catch (ex)
{; }
if (arch=="x86")
return "x86";
if (arch=="AMD64")
return "AMD64";

return "Not found";
}

What does everyone think, would this work.

I am alos looking at doing the same thing for retrieving the Hardware manufacturer, from the BIOS.

Edited by markbb
Link to comment
Share on other sites


Hummm, first try hasn't worked as planned.

On x86, worked exaclty as required, only displayed 32bit apps. (using condition of getArch()=="x86")

On AMD64 system only displayed 32bit apps. (using condition of getArch()=="AMD64").

I'll check again later. Any thoughts anyone on WPI riunning on AMD64 windows?

Link to comment
Share on other sites

OK, so I have tested it a little more.

When I run WPI with the additional code in API.js and with the "Condition" added to the config.js for the architecture. I get the following results.

:- With "condition" of getArch()=="x86" for 32 bit apps and getArch()=="AMD64" for 64 bit apps.

- On x86 machine it will display only 32 bits apps

- On AMD64 machine it will display only 32 bits apps and NOT the 64 bit apps. as the changes should do.

I have run the extra code standalone and it does return x86 for x86 Architecture system and AMD64 for AMD64 Architecture.

So I am a little lost as to why it will not work in WPI.

Is there a way of displaying on the main WPI screen what the contents of getArch() is when I launch WPI?

Link to comment
Share on other sites

Thanks ZORPHNOG for the alert command.

Well I am completely confused by the problem now. As on a AMD64 version of Windows 2003 Server I get the response x86 using the alert command in WPI.HTA

I have changed the code to:

function getArch()
{
position="api.js";
whatfunc="getArch()";

return WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%");

}

So that it only returns the environment variable, but it still thinks it is x86!!!

Is there a problem run

WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")

in WPI?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...