VBScript - How much memory? Processor Info?

Posted on 2006-03-23
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.
Question by:schworgj
    LVL 4

    Expert Comment

    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 Comment

    I have been told that we are not to install anything on these computers. Scripting the install was my first thought too.
    LVL 41

    Accepted Solution

    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

        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

    Author Comment

    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.
    LVL 41

    Expert Comment

    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 Comment

    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.

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now