PDA

View Full Version : [OT] Help me create this script...



MjukisDjur
30-08-04, 21:07
I am working on a simple script that show computer name, diskspace, windows version bla bla bla etc.

Now, I would like to dump the version of Office to the file as well. How in gods name do I do that?
I can use win32_product to dump ALL software installed but i only want the Office part to show.
Can someone tell how to filter the script to only show software with "Microsoft Office" in it?
It can be done, right? I not skilled enough to do such thing.
I can just cut and paste different scripts into one and make it look like I want. :)


Original win32_product script:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Product",,48)
For Each objItem in colItems
Wscript.Echo "Caption: " & objItem.Caption
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "IdentifyingNumber: " & objItem.IdentifyingNumber
Wscript.Echo "InstallDate: " & objItem.InstallDate
Wscript.Echo "InstallDate2: " & objItem.InstallDate2
Wscript.Echo "InstallLocation: " & objItem.InstallLocation
Wscript.Echo "InstallState: " & objItem.InstallState
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "PackageCache: " & objItem.PackageCache
Wscript.Echo "SKUNumber: " & objItem.SKUNumber
Wscript.Echo "Vendor: " & objItem.Vendor
Wscript.Echo "Version: " & objItem.Version
Next



Help me :)

Regards
Mjukisdjur

MjukisDjur
30-08-04, 23:19
To make it a bit more simple for you: show me how to set "filter" on this piece of code: (looked at a ton of arrays and stuff I cannot focus any more :)


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Product",,48)
For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
next


Filter would be microsoft Office to start with. Ill probably add more later...

Mjukisdjur

RayBob
31-08-04, 17:40
You could either add a WHERE clause to the original query to limit which records are retrieved or change this line...

For Each objItem in colItems
Wscript.Echo "Name: " & objItem.Name
next

to.....

For Each objItem in colItems
If objItem.Name Like "*Office*" Then
Wscript.Echo "Name: " & objItem.Name
End If
next

ichinin
31-08-04, 19:26
Not that experienced with VBS, but u can try FSO to get file/disk info and the rest you want is probably best obtained through reading the registry.

Some links that may help you find some source/object documentation:

www.thecodeproject.com (Got a VBScript section)
www.vbdiamond.com
www.vbcode.com

Good luck.