Support Forums

help combining 2 scripts

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Thu Mar 06, 2014 9:13 am

no i want to search both the wow6432 and the 32bit. i guess that didn't work.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Thu Mar 06, 2014 9:25 am

i guess silverlight was a bad example to use in that code cause it doesn't actually have a wow6432node key so none of these scripts work properly.

I apologize, i guess back to the drawing board.
User avatar
jvierra
Posts: 10021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Thu Mar 06, 2014 9:26 am

You need to save the message to the end and output it once.

Are you sure the same GUID is installed in both 32 and 64 bit locations. Usually they are different product GUIDS.

I would check carefully.
User avatar
jvierra
Posts: 10021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Thu Mar 06, 2014 9:42 am

Can you describe what it is you are trying to do.

The Win32_Product class can find a product on both nodes using identical logic.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Thu Mar 06, 2014 10:42 am

yeah i started with the win32_product class but it created several 100 events in the windows app event log.

I'm trying to identify software installed using 1 script per piece of software.

The challenge is sometimes the GUID is different and sometimes the x64 machine keys are located in the wow6432node.

So i want it to check the normal uninstall reg location and if it isn't there then check the wow6432node, and if it isn't there then echo "not installed"

does that help?
User avatar
jvierra
Posts: 10021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Thu Mar 06, 2014 10:48 am

Win32_Product does not place 100 events in the event log when used correctly and it sees both 32 bit and 64 bit installations.

If all of you machines are unpatched XP systems then you will see some delay on querying those. Vista and later use a newer installer that is much faster. I can query a machine for a product specific name and it will resolve in a few seconds.

The code I posted above does query both hives. Just change the message.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Thu Mar 06, 2014 10:52 am

Below is what i was using for the wmi query, it creates events.

i'd love to use this instead if it can be fixed to not create events in the event log. i'm in a win7 enviroment.

VBScript Code
Double-click the code block to select all.
on error resume next

dim svalue

Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\.\root\CIMV2")

Set colSoftware = objWMIService.ExecQuery _
("SELECT * FROM Win32_Product WHERE Name = 'Java(TM) 6 Update 23'")

If colSoftware.Count > 0 Then

For Each objSoftware in colSoftware
svalue = objSoftware.version
Next

If (svalue >="6.0.230") Then
wscript.echo "Compliant"

Elseif (svalue <"6.0.230") Then
wscript.echo svalue

End if

Else
WScript.echo "Not Installed"
End If
User avatar
jvierra
Posts: 10021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Thu Mar 06, 2014 11:34 am

Why are you worried about events in the event log. Almost everything that happens in Windows puts events in the eventlogs.

Are you planning on running this every 5 minutes.

If you are using SCCM then their is another class like WIn32_product that does not put events in the event log.
User avatar
jjimenez
Posts: 12
Joined: Sun Mar 02, 2014 12:28 pm

Re: help combining 2 scripts

Postby jjimenez » Thu Mar 06, 2014 12:48 pm

yeah, i looked through all the classes and they all have some type of event log overhead. the win_32 product class has an exceptional amount of eventlog overhead per software instance. ultimately the REGREAD files work ok i guess.

Thanks for all the help and info, its nice to bounce things off others.
User avatar
jvierra
Posts: 10021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: help combining 2 scripts

Postby jvierra » Thu Mar 06, 2014 1:25 pm

This is a much easier way.

VBScript Code
Double-click the code block to select all.
sProductIdentifier = "{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}"
dversion = "6.1.20913.0"

sVersion = GetProductVersion("HKLM\software\microsoft\windows\currentversion\uninstall\" & sProductIdentifier & "\DisplayVersion")
if sVersion <> "" Then
WScript.Echo sVersion
WScript.Quit
End If

sVersion = GetProductVersion("HKLM\software\wow6432node\microsoft\windows\currentversion\uninstall\" & sProductIdentifier & "\DisplayVersion")
If sVersion <> "" Then
WScript.Echo sVersion
WScript.Quit
End If

WScript.Echo "Not found"

Function GetProductVersion(sValuePath)
On Error Resume Next
GetProductVersion = createobject("wscript.shell").Regread( sValuePath )
End Function

Return to “VBScript”

Who is online

Users browsing this forum: No registered users and 5 guests