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.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jjimenez
Posts: 12
Last visit: Fri Mar 07, 2014 8:23 am

Re: help combining 2 scripts

Post by jjimenez »

no i want to search both the wow6432 and the 32bit. i guess that didn't work.
User avatar
jjimenez
Posts: 12
Last visit: Fri Mar 07, 2014 8:23 am

Re: help combining 2 scripts

Post 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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: help combining 2 scripts

Post 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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: help combining 2 scripts

Post 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.
User avatar
jjimenez
Posts: 12
Last visit: Fri Mar 07, 2014 8:23 am

Re: help combining 2 scripts

Post 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?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: help combining 2 scripts

Post 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.
User avatar
jjimenez
Posts: 12
Last visit: Fri Mar 07, 2014 8:23 am

Re: help combining 2 scripts

Post 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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: help combining 2 scripts

Post 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.
User avatar
jjimenez
Posts: 12
Last visit: Fri Mar 07, 2014 8:23 am

Re: help combining 2 scripts

Post 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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: help combining 2 scripts

Post 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
This topic is 10 years and 3 weeks old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked