esullivan Posted November 16, 2015 Share Posted November 16, 2015 I found this to search for an installed program:expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <InetConstants.au3> #include <MsgBoxConstants.au3> #Include <String.au3> #include <INet.au3> #include <Array.au3> #include <File.au3> If IsInstalled("Adobe Flash Player 19 NPAPI") == 1 Then msgbox("","", "Installed") Else msgbox("","", "Not installed") EndIf Func IsInstalled($progName) Local $InstallPrograms = GetList() If $InstallPrograms == -1 Then Return -1 ; Cannot get list For $program in $InstallPrograms if StringLower($program.Caption) == StringLower($progName) Then ConsoleWrite($program.Caption & " : " & $progName & @CRLF) Return 1; EndIf Next Return -2 ; Didn't find program. EndFunc Func GetList() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output &= "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then Return $colItems EndIf Return -1 EndFuncAnd it works, however you have to have the exact name of the program, for example "Adobe Flash Player 19 NPAPI". I'd like to be able to search for just "Flash". Anyone able to modify this for that? Or have a better way? Link to comment Share on other sites More sharing options...
Danyfirex Posted November 16, 2015 Share Posted November 16, 2015 stringinstr is your friend.Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Danyfirex Posted November 16, 2015 Share Posted November 16, 2015 expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <InetConstants.au3> #include <MsgBoxConstants.au3> #Include <String.au3> #include <INet.au3> #include <Array.au3> #include <File.au3> If IsInstalled("Flash") == 1 Then msgbox("","", "Installed") Else msgbox("","", "Not installed") EndIf Func IsInstalled($progName) Local $InstallPrograms = GetList() If $InstallPrograms == -1 Then Return -1 ; Cannot get list For $program in $InstallPrograms if StringInStr(StringLower($program.Caption),StringLower($progName)) Then ConsoleWrite($program.Caption & " : " & $progName & @CRLF) Return 1; EndIf Next Return -2 ; Didn't find program. EndFunc Func GetList() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output &= "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then Return $colItems EndIf Return -1 EndFuncSaludos esullivan 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
esullivan Posted November 16, 2015 Author Share Posted November 16, 2015 Thanks Dany! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 16, 2015 Moderators Share Posted November 16, 2015 Also, if the functions are not part of a larger script where you need them, there is a lot of fluff. You could easily trim it down to something like this and save yourself 30 lines:$wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $Program = "Flash" $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $app In $colItems If StringInStr(StringLower($app.Caption),StringLower($Program)) Then ConsoleWrite($app.Caption & " : " & $app & @CRLF) EndIf Next EndIf "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now