Jump to content

Find specific program using WMI


Recommended Posts

I am trying to create script that will search the PC using WMI for a specific program, and if it matches the specified program a message pops up saying the program is up-to-date. If the version numbers do not match, then the program is executed to silently install.

This is what I have:

#include <ExplorerCopy.au3>

_IntelChk()

Func _IntelChk()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"

    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", _
                                              $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems
            $Output1 = $Output & $objItem.Name & @CRLF
            $Output2 = $Output & $objItem.Version & @CRLF
            If $Output1 = "Intel(R) PROSet/Wireless WiFi Software" And $Output2 = "13.03.0000" Then
                MsgBox(0,"Intel PROSet Wireless","You are running the latest version of the Intel Wireless Software.")
            Else
                MsgBox(0,"Intel PROSet Wireless","The Intel PROSet Wireless application is out of date." & @CR & "The latest version will now be installed in the background." & @CR & "NOTE: You will lose wireless connectivity during this up date. Users on docking stations will notice no connectivity issues.",8)
                _ExplorerCopy("\\servername\sharename\Intel Wireless\Intel PROSet Wireless.msi","C:\Windows\!DriverCache\Intel 3945 ABG Drivers and Wireless Profile\",BitOR($FOF_SIMPLEPROGRESS,$FOF_NOERRORUI,$FOF_NOCOPYSECURITYATTRIBS,$FOF_NOCONFIRMMKDIR,$FOF_NOCONFIRMATION))
                MsgBox(0,"Intel PROSet Wireless","The Intel PROSet Wireless installation is about to begin.",5)
                ;RunWait('msiexec /i "C:\Windows\!DriverCache\Intel 3945 ABG Drivers and Wireless Profile\Intel PROSet Wireless.msi" /qb /norestart ADDLOCAL=WIFI_Driver,WIFI_Software,WIFI_UI,WIFI_SSO,WIFI_PLC,WIFI_Simple_Config,WIFI_Troubleshooter,WIFI_Help,WIFI_Custom_Help')
                MsgBox(0,"Intel PROSet Wireless","The Intel PROSet Wireless application has now been updated.")
                ExitLoop
            EndIf
            ;$Output=""
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" )
    Endif
EndFunc

It seems the program is not correctly picking up the version number. If I use the ScriptOMatic tool, then I am told the version number. I think because it is scanning all the programs on the PC, the variable is not being set correctly.

Can someone help me figure this out please?

Thanks,

Jeff

Link to comment
Share on other sites

Hi.

As I don't have any software, that the Scriptomatic would be able to pull a version from, I cannot check your example, that query from ScriptomaticV2.hta is giving me an empty result. (Just displays the computername, that's it)

Anyways, I'd like to suggest two different approaches:

1.) Scan for the Version value "DisplayVersion" here: HKLM\software\microsoft\windows\currentversion\uninstall\<key-of-your-product>\

2.) If you know, where the DLL/EXE is, that you want to update, then use FileGetVersion() and _VersionCompare()

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

What's up with your output variable assignments? You're concatenating a blank string, the variable, and a carriage return? More than likely your comparisons aren't working because of the carriage returns. Try using this and see if your results are different.

If $objItem.Name = "IntelĀ® PROSet/Wireless WiFi Software" And $objItem.Version = "13.03.0000" Then
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...