Sign in to follow this  
Followers 0
jazzyjeff

Find specific program using WMI

23 posts in this topic

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

Share this post


Link to post
Share on other sites



What if you just run this:

_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
            ConsoleWrite("Name = " & $Output1 & "Version = " & $Output2)
        Next
    Else
        MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_Product")
    EndIf
EndFunc   ;==>_IntelChk

If that works fine (as it does for me) then it's just how you are parsing the results.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks for the quick response. This is the output that I receive:

----------

Name = Symantec Ghost Standard Tools

Version = 115.00.2113

Name = Intel® PROSet/Wireless WiFi Software

Version = 13.03.0000

Name = Orca

Version = 3.1.3790.0000

Name = Microsoft Download Manager

Version = 1.0.1

Name = SlingPlayer

Version = 2.0.4521

----------

This is great because I can see that the program I am searching for is listed. What I am trying to achieve though is to be able to extract just 1 "name" and 1 "version" from that list, and then apply those outputs to variables. I don't think it is doing that at the moment because it just sees the entire output as a value for the variable. If I am completely misunderstanding this please let me know.

Thinking about it somemore, I think I could export all this data into a text file and then read the file for the specific values, but it seems that there must be a way to pick out the values that you want from this list.

Share this post


Link to post
Share on other sites

Just at a quick glance, and not having tested this, but the fact that you are adding a @CRLF to the end of each output variable, and then comparing those to static strings without @CRLF on the end might be causing it not to run.

If nothing else, it doesn't read very well to see the variables done this way.

Share this post


Link to post
Share on other sites

@jazzyjeff

As you can see from PsaltyDS's example, he's not searching for a specific program with it. You need to add in your If statements to only look for the Intel program you need to get the information from. Once you do that, you will have your script looking at the right information.

By the way, in your original script, you're looking for a specific version number, which I'm guessing is the latest version. You might want to code it so that the version search string is a variable that you set earlier in the script. This way, if the version changes again, you only have to change the value of the variable, this would only be a help if you use the version information more than once in the script.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yeah, what SkinnyWhiteGuy said. :)

Drop the @CRLF, or use StringInStr()/StringRegExp()/etc. to test the string with.

Additionally, you could refine your WQL query to get more of what you want and less of what you don't:

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product WHERE Name LIKE 'Intel%'", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

Or even:

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product WHERE Name = 'Intel® PROSet/Wireless WiFi Software'", "WQL", _
            $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

;)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks SkinnyWhiteGuy. I actually also tried removing those lines prior to posting this topic, but it didn't make a difference. They are removed at present.

Thank you all for your replies. I feel stupid when I send these requests and then with a bit more studying I figure it out!

So after reading about WMI, I've learned a little about how to utilise the code. This has resolved the issue for me:

#include <ExplorerCopy.au3>

_IntelChk()

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

    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
    $colItems = $objWMIService.ExecQuery("SELECT Name, Version FROM Win32_Product WHERE Name = 'Intel(R) PROSet/Wireless WiFi Software' and Version = '13.03.0000'", "WQL", _
                                              $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems
            $Output1 = $objItem.Name
            $Output2 = $objItem.Version
            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("\\app2\k-12$\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))
                ;RunWait('cmd.exe /c xcopy "\\app2\k-12$\Intel Wireless\Intel PROSet Wireless.msi" "C:\Windows\!DriverCache\Intel 3945 ABG Drivers and Wireless Profile\" /C /Y',"",@SW_HIDE)
                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

Thank you all for your time and help.

Share this post


Link to post
Share on other sites

Double check and see if that actually works when you have a incorrect version/missing software. From the looks of it, I'm betting it won't.

Share this post


Link to post
Share on other sites

SkinnyWhiteGiy, you're bursting my bubble here mate! :-)

I'll test this when I get back in the office later.

Share this post


Link to post
Share on other sites

Darn! Well I thought I had it, but it turns out you're right. It doesn't work if the program is not installed. Do you have any suggestions on how I can get around this please?

Thanks

Share this post


Link to post
Share on other sites

If it's not installed, your loop won't ever run. You could use a boolean variable, always set to false at the start of the script, and have where if it see's the app installed (your message box that declares it installed) set the variable to true. After the loop, check to see if it got changed, and if not, then install it.

Share this post


Link to post
Share on other sites

Start by uncommenting the RunWait lines, then do a check to see if the file exists but is the wrong version. Currently your test line only checks to see if it exists AND is the correct version. You have no check there to see if it exists and is the wrong version, nor do you have a test to see if it doesn't exist. You just need to add some ElseIf lines under your first If line.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

You da man! That worked.

Thank you.

Share this post


Link to post
Share on other sites

Just wanted to let you know the script that worked for me, and maybe it'll help someone else out in future.

#include <ExplorerCopy.au3>
$intelChk = False
_IntelChk()
If $intelChk = False Then
    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("\\app2\k-12$\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.")
    Exit
Else
    MsgBox(0,"Intel PROSet Wireless","The Intel PROSet Wireless application is already installed.")
EndIf

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


    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
    $colItems = $objWMIService.ExecQuery("SELECT Name, Version FROM Win32_Product WHERE Name = 'Intel(R) PROSet/Wireless WiFi Software' and Version = '13.03.0000'", "WQL", _
                                              $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems
            $Output1 = $objItem.Name
            $Output2 = $objItem.Version
            If $Output1 = "Intel(R) PROSet/Wireless WiFi Software" And $Output2 = "13.03.0000" Then
                $intelChk = True
            EndIf
            ExitLoop
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" )
    Endif
EndFunc

Share this post


Link to post
Share on other sites

OK, so I need to extend the functionality of this script to check the PC model when it launches. I thought that this would be easy now I already have the check in place to determine the Intel Software version, as I can basically use the same method. I was wrong!

This is what I have:

#include <ExplorerCopy.au3>
$intelChk = False
$PCChk = False
Global $Model

_PCChk()
_IntelChk()
MsgBox(0,"PC Model",$Model)
MsgBox(0,"Boolean Value",$PCChk)


If $PCChk = False Then
    Exit
Else
    _Intel()
EndIf

Func _Intel()
    If $intelChk = False Then
        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("\\app2\k-12$\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.")
        Exit
    Else
        MsgBox(0,"Intel PROSet Wireless","The Intel PROSet Wireless application is already installed.")
        Exit
    EndIf
EndFunc

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

    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
    $colItems2 = $objWMIService.ExecQuery('SELECT Model FROM Win32_ComputerSystem', "WQL", _
                                              $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems2) Then
        For $objItem2 In $colItems2
            $Model = $objItem2.Model
            If $Model = "Latitude D830" Or StringInStr($Model,"HP Compaq 6710b") Then
                $PCChk = True
            EndIf
            ExitLoop
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" )
    Endif
EndFunc

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


    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
    $colItems = $objWMIService.ExecQuery("SELECT Name, Version FROM Win32_Product WHERE Name = 'Intel(R) PROSet/Wireless WiFi Software' and Version = '13.03.0000'", "WQL", _
                                              $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems
            $Output1 = $objItem.Name
            $Output2 = $objItem.Version
            If $Output1 = "Intel(R) PROSet/Wireless WiFi Software" And $Output2 = "13.03.0000" Then
                $intelChk = True
            EndIf
            ExitLoop
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" )
    Endif
EndFunc

The _Intel() function works fine, but the _PCChk() function does not, and I don't get why. They both use the same checking methods, which I though would work fine.

I put the MSGBOX windows at the start of the script, so I could check that it was pulling the correct value from the BIOS. Sure enough, it tells me that my PC is a "Latitude D830". I specify in the script that if $PCChk variable = "Latitude D830", then the Boolean value is True. The 2 variables match, but it tells me that the Boolean value is FALSE. I don't understand why.

If someone can help me on this, I'd appreciate it.

If I need to make a new post, please let me know and I'd be happy to start a new topic.

Thanks.

Jeff

Share this post


Link to post
Share on other sites

I ran your script with my laptop, substituting my model's name for the latitude d830 and it works for me. I also used it and replaced the HP model name in the StringInStr check and it worked that way also. So, I'm not sure why it's not working for you. Try replacing the code where you look for the Latitude D830 with a StringInStr looking for the model. Perhaps there's a space after the name that you don't see in the MsgBox for $Model that's messing it up.

I did notice that, on my computer, the _IntelChk never gets to the For $objItem In $colItems...Next loop. I put a MsgBox right after the For part of the loop and the box never shows up. When I put the MsgBox just before it, it shows.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

BrewManNH,

Thanks for the reply.

I tried your suggestion adding the StringInStr for the $Model variable, but this didn't make a difference.

I modified the script to tell me in the MSGBOX how it reads the $PCCHK Boolean variable and it reports nothing, but it should tell me if the value is FALSE or TRUE. This is where I think the problem lies in that it's not reading the boolean value correctly in this part of the script:

If IsObj($colItems2) Then
        For $objItem2 In $colItems2
            $Model = $objItem2.Model
            If $Model = StringInStr($Model,"Latitude D830") Or StringInStr($Model,"HP Compaq 6710b") Then
                $PCChk = True
            EndIf
            ExitLoop
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" )
    Endif

I modified the complete script to look like this. If you run the script below, does it give you a boolean variable (True,False)? It seems like it should return a value.

#include <ExplorerCopy.au3>
$intelChk = False
;$PCChk = False
Global $Model,$PCChk

_PCChk()
_IntelChk()
MsgBox(0,"PC Model",$Model)
MsgBox(0,"Boolean Value",$PCChk)


If $PCChk = False Then
    Exit
Else
    _Intel()
EndIf

Func _Intel()
    If $intelChk = False Then
        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("\\app2\k-12$\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.")
        Exit
    Else
        MsgBox(0,"Intel PROSet Wireless","The Intel PROSet Wireless application is already installed.")
        Exit
    EndIf
EndFunc

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

    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
    $colItems2 = $objWMIService.ExecQuery('SELECT Model FROM Win32_ComputerSystem', "WQL", _
                                              $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems2) Then
        For $objItem2 In $colItems2
            $Model = $objItem2.Model
            If $Model = StringInStr($Model,"Latitude D830") Or StringInStr($Model,"HP Compaq 6710b") Then
                $PCChk = True
            EndIf
            ExitLoop
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" )
    Endif
EndFunc

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


    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\")
    $colItems = $objWMIService.ExecQuery("SELECT Name, Version FROM Win32_Product WHERE Name = 'Intel(R) PROSet/Wireless WiFi Software' and Version = '13.03.0000'", "WQL", _
                                              $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) Then
        For $objItem In $colItems
            $Output1 = $objItem.Name
            $Output2 = $objItem.Version
            If $Output1 = "Intel(R) PROSet/Wireless WiFi Software" And $Output2 = "13.03.0000" Then
                $intelChk = True
            EndIf
            ExitLoop
        Next
    Else
        Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" )
    Endif
EndFunc

Share this post


Link to post
Share on other sites

I did notice that, on my computer, the _IntelChk never gets to the For $objItem In $colItems...Next loop. I put a MsgBox right after the For part of the loop and the box never shows up. When I put the MsgBox just before it, it shows.

Because the query searches for a specific value of name='Intel® PROSet/Wireless WiFi Software' etc., it won't return a collection if you don't have that specific hardware installed. That causes "If IsObj($colItems) Then" to be false and skip the loop.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Brain fart on my part regarding the IntelChk, I didn't even look at what it was looking for.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

:-) No worries. The IntelChk function does work fine. I have tested this on numerous machines as a separate script, and it's working fine. This is why I don't understand how the IntelChk Function can return the Boolean value and not the PCChk Function. Maybe it's to do with the value that it's trying to check against i.e. Latitude D830.

I ran the script from Scriptomatic though that tells me all the WMI values in WIN32_ComputerSystem, and the "Model" WMI value is what I have in the $model variable.

Share this post


Link to post
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
Sign in to follow this  
Followers 0