Results 1 to 4 of 4

Thread: Assistance needed with inherited script..

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    2

    Assistance needed with inherited script..

    Hi All,
    Im new to this Vb stuff. Ive been doing a little autoit scripting but ive now inherited a VB script i need to modify but dont know how. Somone has shown me what i need to do but written in Auto it. Could somone assist me in translating that process into my exisitng VB script.

    At present my Vb script pulls PC information into a database for an inventory. it uses WIM classes to pull the information. i have modifed a fiew of the fields as ther were recording incorect information. i would like to add a field in my database telling me how many memory slots in a PC are in use. ive searched but could not find a class ID to pull this information but a helpfull guy created this autoit script which gives me that info from exisitng classes.

    Code:
    ; Generated by AutoIt Scriptomatic
    
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"
    
    $Output=""
    $Output = $Output & "Computer: " & $strComputer  & @CRLF
    $Output = $Output & "==========================================" & @CRLF
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMemory", "WQL", _
                                              $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    $numMemSticks = 0
    If IsObj($colItems) then
       For $objItem In $colItems
            $numMemSticks += 1
          $Output = $Output & "BankLabel: " & $objItem.BankLabel & @CRLF
          $Output = $Output & "Capacity: " & $objItem.Capacity & @CRLF
          $Output = $Output & "Caption: " & $objItem.Caption & @CRLF
          $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF
          $Output = $Output & "DataWidth: " & $objItem.DataWidth & @CRLF
          $Output = $Output & "Description: " & $objItem.Description & @CRLF
          $Output = $Output & "DeviceLocator: " & $objItem.DeviceLocator & @CRLF
          $Output = $Output & "FormFactor: " & $objItem.FormFactor & @CRLF
          $Output = $Output & "HotSwappable: " & $objItem.HotSwappable & @CRLF
          $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF
          $Output = $Output & "InterleaveDataDepth: " & $objItem.InterleaveDataDepth & @CRLF
          $Output = $Output & "InterleavePosition: " & $objItem.InterleavePosition & @CRLF
          $Output = $Output & "Manufacturer: " & $objItem.Manufacturer & @CRLF
          $Output = $Output & "MemoryType: " & $objItem.MemoryType & @CRLF
          $Output = $Output & "Model: " & $objItem.Model & @CRLF
          $Output = $Output & "Name: " & $objItem.Name & @CRLF
          $Output = $Output & "OtherIdentifyingInfo: " & $objItem.OtherIdentifyingInfo & @CRLF
          $Output = $Output & "PartNumber: " & $objItem.PartNumber & @CRLF
          $Output = $Output & "PositionInRow: " & $objItem.PositionInRow & @CRLF
          $Output = $Output & "PoweredOn: " & $objItem.PoweredOn & @CRLF
          $Output = $Output & "Removable: " & $objItem.Removable & @CRLF
          $Output = $Output & "Replaceable: " & $objItem.Replaceable & @CRLF
          $Output = $Output & "SerialNumber: " & $objItem.SerialNumber & @CRLF
          $Output = $Output & "SKU: " & $objItem.SKU & @CRLF
          $Output = $Output & "Speed: " & $objItem.Speed & @CRLF
          $Output = $Output & "Status: " & $objItem.Status & @CRLF
          $Output = $Output & "Tag: " & $objItem.Tag & @CRLF
          $Output = $Output & "TotalWidth: " & $objItem.TotalWidth & @CRLF
          $Output = $Output & "TypeDetail: " & $objItem.TypeDetail & @CRLF
          $Output = $Output & "Version: " & $objItem.Version & @CRLF
    ;~       if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
          $Output=""
       Next
    Else
       Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_PhysicalMemory" )
    Endif
    MsgBox(0,"Memory", "Number of Mem Sticks: " & $numMemSticks)
    
    Func WMIDateStringToDate($dtmDate)
    
        Return (StringMid($dtmDate, 5, 2) & "/" & _
        StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
        & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
    EndFunc


    i currently have this in my VB script for that class but need to add the looping process to get the memory sticks No. for another fields in my data base..

    Code:
    Next
    Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)
    For Each objItem in colItems
    	strRAMSpeed = objItem.Speed
     	strRAMBanks = objItem.DeviceLocator
    
    next
    i would like the No. of the slots used to go into the RAMBanks Field I currently have the Devicelocator in.


    all help is greatly apreciated.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Assistance needed with inherited script..

    Welcome to the Forums.

    Scriptomatic is a WMI sctipting utility from MS. But to use this in .NET I would suggest using .NET code and classes instead.

    Search in CodeBank as gigemboy wrote some code for obtaining hardware info using .NET.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    2

    Re: Assistance needed with inherited script..

    RodDog888,
    Thanks for the link. ive looked but it dosent help me any more at present.

    I know from hours & hours of searching the classes from msdn & scriptomatic that there isnt an actual class to get the number of mem slots used. All i need to do is to translate what is in the looping bit in the autoit script into my VB script. this gives you from looping several times how many sticks are installed.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Assistance needed with inherited script..

    You use some of the classes like ManagementObjectSearcher to retrieve the hardware info you seek with a wmi query.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width