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