Page 2 of 3

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 8:13 am
by jjimenez
no i want to search both the wow6432 and the 32bit. i guess that didn't work.

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 8:25 am
by jjimenez
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.

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 8:26 am
by jvierra
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.

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 8:42 am
by jvierra
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.

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 9:42 am
by jjimenez
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?

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 9:48 am
by jvierra
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.

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 9:52 am
by jjimenez
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

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 10:34 am
by jvierra
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.

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 11:48 am
by jjimenez
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.

Re: help combining 2 scripts

Posted: Thu Mar 06, 2014 12:25 pm
by jvierra
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