We help IT Professionals succeed at work.

VBScript - How much memory? Processor Info?

schworgj
schworgj asked
on
Medium Priority
487 Views
Last Modified: 2008-01-09
I need to get the RAM (total/free) and the processor info (speed/type) without using the WMI because this script will run on Win95/98 boxes that might not have WMI installed.
Comment
Watch Question

Commented:
If it were me, I would script the installation of WMI (via login script) on those Win9x boxes since permissions aren't an issue. The vbScript could then check if WMI is present, collect the inventory. I have an old kixtart script I could post that installs WMI. I know your question was about vbScript, but you can lauch a kixtart script from within vbScript.

Author

Commented:
I have been told that we are not to install anything on these computers. Scripting the install was my first thought too.
Commented:
That's a tall order... particularly if your stuck with VBScript and can't use WMI

The CPU Identifieris at HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0.   On newer OS (but not Win9x), the CPU speed is also at that location

Memory can be obtained using the GlobalMemoryStatus API

Type MEMORYSTATUS
    dwLength As Long
    dwMemoryLoad As Long
    dwTotalPhys As Long
    dwAvailPhys As Long
    dwTotalPageFile As Long
    dwAvailPageFile As Long
    dwTotalVirtual As Long
    dwAvailVirtual As Long
End Type

Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)

    Dim mem As MEMORYSTATUS
    Dim mb As Long
 
    mem.dwLength = Len(mem)
    GlobalMemoryStatus mem
    ' add 384k to account for upper memory area
    mb = (mem.dwTotalPhys + 393216) / 1048576
   
    ' round off to nearest MB
    If ((mb * 1048576) - mem.dwTotalPhys - 393216) > 524288 Then
        mb = mb + 1
    End If

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Can't use this code in VBScript. At least not the memory section. Thanks for the registry location of the processor.  I'll leave the question open a bit longer to see if I can get the memory part answered too then split the points accordingly.

Commented:
Yeah, if you're stuck with VBScript, your hands are kinda tied.   However VBScript can use DLLs.  For example, there are a lot of good CPU detection/speed tools available as COM-based DLLs.

Are you at least allowed to register a DLL on these PCs?

Author

Commented:
I got the CPU info out of the registry. It isn't as much info as we would like but it will do. I am amazed that there isn't a simple way to check total/free memory without some DLL or WMI. VBScript is pretty limited in what it can do without external tools.

I don't think we are supose to put anything beyond the single script on the user's PC. Actually, the script is sitting on a network drive and just gets called. Long story but we are trying not to actually install anything beyond a shortcut to this script.

Driving me nuts.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.