AntiVirusGuy Posted December 21, 2006 Share Posted December 21, 2006 here is what I am trying to do $MYAPP = "Trend" or "McAfee" or "Norton" ; I know OR will not work but this is what I need to do $UNINSTALLSTRING = GetUninstallString($MYAPP) any idea how to specify multiple strings? Link to comment Share on other sites More sharing options...
FreeFry Posted December 21, 2006 Share Posted December 21, 2006 (edited) Well you will need an If to check for if the different programs exists... Like... If FileExists("PathToInstallDirForNorton\Norton.exe") Then $MYAPP = "Norton" If FileExists("PathToInstallDirForTrend\Trend.exe") Then $MYAPP = "Trend" If FileExists("PathToInstallDirForMcAfee\McAfee.exe") Then $MYAPP = "McAfee" Edit: There's probably other ways to detect if they are installed.. Maybe using RegRead() to read some entry from the system registry... Defining multiple variables can be done by separating them with a , sign ie. Dim $Var1, $Var2, $Var3 Edited December 21, 2006 by FreeFry Link to comment Share on other sites More sharing options...
xcal Posted December 21, 2006 Share Posted December 21, 2006 Ultimately, I think you'll end up having to check some sort of condition. If something then $myapp = this elseif something then etc etc. You'll probably have to get your condition by taking a peek in the users registry. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted December 21, 2006 Share Posted December 21, 2006 ???? Global $MYAPP[3] = ["Trend","McAfee","Norton"] Global $UNINSTALLSTRING[3] For $i = 0 To UBound($MYAPP) - 1 $UNINSTALLSTRING[$i] = GetUninstallString($MYAPP) Next Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 I am scanning the registry for any installed antivirus the problem is companies like Norton and Mcafee and Trend do not use the key word antivirus so I am scanning the uninstall keys for all potential programs. I want to keep it confined to the registry. any thoughts? As allways thank you, your expertise is greatly appreciated. Link to comment Share on other sites More sharing options...
FreeFry Posted December 21, 2006 Share Posted December 21, 2006 (edited) One way would be to map where all anti-viruses gets installed to(at least those that you support). Then use FileExist() to check if they are installed or not Another way would be to find out any registry entries they make when they are installed, and just RegRead those to check if they are installed. Your choice. Edited December 21, 2006 by FreeFry Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 this is what I get Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $UNINSTALLSTRING[$i] = GetUninstallString($MYAPP) ^ ERROR Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 I need to support all products all versions. all the installed apps are in [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall] I can currently scan for a single name but I need to be able to look for all names Link to comment Share on other sites More sharing options...
FreeFry Posted December 21, 2006 Share Posted December 21, 2006 If you would provide us with your code it might be a little easier to help you. Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 ;here it is many people have helped me I don't pretend to half understand it as I do not have a programming background$MYAPP = "Trend" $UNINSTALLSTRING = GetUninstallString($MYAPP)$Dispaly = GetDispalyName($MYAPP);if $Dispaly = "0" then MsgBox(64, "Not Found", "No existing Anti Virus found", 3) Else #Region --- CodeWizard generated code Start ---;MsgBox features: Title=Yes, Text=Yes, Buttons=OK and Cancel, Icon=NoneIf Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer$iMsgBoxAnswer = MsgBox(36, 'Found:', $Dispaly & @CRLF & 'Has been Found, do you want to uninstall it?')Select Case $iMsgBoxAnswer = 6 ;OK Runwait($UNINSTALLSTRING) Case $iMsgBoxAnswer = 7 ;Cancel ExitEndSelectEndif#EndRegion --- CodeWizard generated code End ---TrayTip("Installing", "New Antivirus", 30, 1)RunWait(@TempDir & "\newav.exe")Sleep(2000)ProcessWaitClose("setup.exe")TrayTip("", "", 0)MsgBox(64,"Success!", "Newav has Installed please reboot your computer", 4);If Not @error Then Run($UNINSTALLSTRING)Func GetUninstallString($app) Local $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" $i = 0 While 1 $i += 1 Local $subkey = RegEnumKey($key, $i) If @error Then ExitLoop ;If @error Then ContinueLoop Local $displayname = RegRead($key & "\" & $subkey,"DisplayName") If StringInStr($displayname, $app) Then Return RegRead($key & '\' & $subkey, 'UninstallString') WEnd Return SetError(1, 0, 0)EndFuncFunc GetDispalyName($app) Local $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" $i = 0 While 1 $i += 1 Local $subkey = RegEnumKey($key, $i) If @error Then ExitLoop ;If @error Then ContinueLoop Local $displayname = RegRead($key & "\" & $subkey,"DisplayName") If StringInStr($displayname, $app) Then Return $displayname WEnd Return SetError(1, 0, 0)EndFunc Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 It would also be cool if it went in a loop in case the user has more than one product installed but I need to work this out first Link to comment Share on other sites More sharing options...
xcal Posted December 21, 2006 Share Posted December 21, 2006 #include <array.au3> Dim $regArray[1], $avArray[4] = ['trend', 'mcafee', 'norton', 'avg'] ;stick your keywords per av software here $i = 0 While 1 $i += 1 $regval = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i) If @error <> 0 then ExitLoop _ArrayAdd($regArray, $regval) WEnd For $i = 1 To UBound($regArray) - 1 For $x = 0 To UBound($avArray) - 1 If StringInStr($regArray[$i], $avArray[$x]) Then $avApp = $avArray[$x] ExitLoop 2 EndIf Next Next MsgBox(0, '', $avApp) How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 this is what I get (22) : ==> Variable used without being declared.: MsgBox(0, '', $avApp) MsgBox(0, '', ^ ERROR just to make sure you know what I am trying to do. I am searching the display name then if I find a match I want to grab it's uninstall key like the above code. Again thank you so much for all the help Link to comment Share on other sites More sharing options...
FreeFry Posted December 21, 2006 Share Posted December 21, 2006 (edited) expandcollapse popupDim $SupportedApps = "Trend,McAfee,Norton,Messenger,Winamp,Windows" ; Add more AV's here, separate them with a comma (,) Dim $Exlude = "My Antivirus" ; seriously, you need a better name :P Dim $MyApps = StringSplit($SupportedApps, ",") Dim $InstalledAppsCount = 1 Dim $Found = 0 TrayTip("Scanning...", "Scanning registry for installed AntiVirus(es).", 5) While 1 $SubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $InstalledAppsCount) If @error Then ExitLoop $DisplayName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $SubKey, "DisplayName") $Uninstallstring = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $SubKey, "UninstallString") For $i = 1 To $MyApps[0] If $DisplayName = $Exlude Then ExitLoop ElseIf StringInStr($DisplayName, $MyApps[$i]) Then $Found += 1 If MsgBox(36, 'Found:', $DisplayName & @CRLF & 'Has been Found, do you want to uninstall it?') = 6 Then RunWait($Uninstallstring) Else ContinueLoop EndIf EndIf Next $InstalledAppsCount += 1 WEnd If Not $Found Then MsgBox(64, "Not Found", "No existing Anti Virus found", 3) Else MsgBox(64, "Found", "Found " & $Found & " installed antivirus.") EndIf TrayTip("Installing", "New Antivirus", 30, 1) RunWait(@TempDir & "\newav.exe") ProcessWait("setup.exe") ProcessWaitClose("setup.exe") TrayTip("", "", 0) MsgBox(64,"Success!", "Newav has Installed please reboot your computer", 4) Hope this works for you. Edited December 21, 2006 by FreeFry Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 (edited) the only thing is the AV count came out at 177 when I had two installed. This seemed to cure it MsgBox(64, "Found", "Found " & $InstalledAppsCount -176 & " installed antivirus.") also to add another product I did this Dim $MyApps[4][2] = [["Trend"], ["nod32"], ["Norton"], ["symantec"]] is this correct? Edited December 21, 2006 by ssebrownatcolby Link to comment Share on other sites More sharing options...
xcal Posted December 21, 2006 Share Posted December 21, 2006 this is what I get (22) : ==> Variable used without being declared.: MsgBox(0, '', $avApp) MsgBox(0, '', ^ ERROR just to make sure you know what I am trying to do. I am searching the display name then if I find a match I want to grab it's uninstall key like the above code. Again thank you so much for all the help The error is if it doesn't find a match... you can do your own error checking. Change the message box to the below and you'll see how the uninstall string is returned. MsgBox(0, '', 'your search string: ' & $avApp & @CRLF & 'string in registry: ' & $regArray[$i]) How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
FreeFry Posted December 21, 2006 Share Posted December 21, 2006 (edited) I changed the code, and added a comment to ease the use of implementing support for more AV's (I had accidently made an error with the array - lol) Edit: Fixed the error when it added every installed app to the found count old code updated Edited December 21, 2006 by FreeFry Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 is there a way to exclude "My AV" from the scan? Link to comment Share on other sites More sharing options...
FreeFry Posted December 21, 2006 Share Posted December 21, 2006 Dim $SupportedApps = "Trend,McAfee,Norton" ; Add more AV's here, separate them with a comma (,) It only finds those that are in that variable, ie. Trend, McAfee and Norton. Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted December 21, 2006 Author Share Posted December 21, 2006 new code only finds one AV will not look for others. also another thought if I wanted to look for key words like antivirsus since some of these companies have other products how do I exclude "My antivirus"? 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