Sobe Posted July 31, 2013 Share Posted July 31, 2013 I'm attempting to remove google chrome from all machines in our corporate enviroment.. First it cycles to find the user accounts, then it cycles through the Application folder for different Chrome versions. For now I'm just copying a file to directory for testing purposes, but it will not exit the loop if version folders are detected. Sorry if not very clear, first time poster, long time lurker :-) Here's my code: $dirlist = FileFindFirstFile("C:Users*.*") If $dirlist <> -1 Then While 1 $dir = FileFindNextFile($dirlist) If @error Then ExitLoop If FileExists("C:Users" & $dir & "AppDataLocalGoogleChromeApplication") Then $verlist = FileFindFirstFile("C:Users" & $dir & "AppDataLocalGoogleChromeApplication*.*") If $verlist <> -1 Then While 1 $ver = FileFindNextFile($verlist) If @error Then ExitLoop If FileExists("C:Users" & $dir & "AppDataLocalGoogleChromeApplication" & $ver & "Installersetup.exe") Then FileCopy(@scriptdir & "filestest.txt" , "C:Users" & $dir & "AppDataLocalGoogleChromeApplication" & $ver & "Installertest.txt" , 9) EndIf WEnd EndIf EndIf WEnd EndIf Link to comment Share on other sites More sharing options...
FireFox Posted August 1, 2013 Share Posted August 1, 2013 Hi, Welcome to the autoit forum Please use autoit code tags to post your code. You should document yourself on the uninstall parameters to fit your needs. Try this (not tested) :Example() Func Example() Local $hDirList = FileFindFirstFile("C:\Users\*.*") If $hDirList = -1 Then Return 0 Local $sDir = "", $hVerList = 0, $sVer = "" While 1 $sDir = FileFindNextFile($hDirList) If @error Then ExitLoop If StringInStr(FileGetAttrib("C:\Users\" & $sDir), "D") = 0 Then ContinueLoop ;not a folder If FileExists("C:\Users\" & $sDir & "\AppData\Local\Google\Chrome\Application") = 0 Then ContinueLoop $hVerList = FileFindFirstFile("C:\Users\" & $sDir & "\AppData\Local\Google\Chrome\Application\*.*") If $hVerList = -1 Then ContinueLoop While 1 $sVer = FileFindNextFile($hVerList) If @error Then ExitLoop If FileExists("C:\Users\" & $sDir & "\AppData\Local\Google\Chrome\Application\" & $sVer & "\Installer\setup.exe") = 0 Then ContinueLoop ShellExecuteWait("C:\Users\" & $sDir & "\AppData\Local\Google\Chrome\Application\" & $sVer & "\Installer\setup.exe", "--uninstall --multi-install --chrome --system-level") WEnd FileClose($hVerList) WEnd FileClose($hDirList) EndFunc Br, FireFox. Link to comment Share on other sites More sharing options...
Sobe Posted August 1, 2013 Author Share Posted August 1, 2013 Thanks very much for the help! I modified what you gave me slightly, but if anyone else wants the code, here's what I'm using. expandcollapse popupChromeRemoval() Func ChromeRemoval() If $opsys = "Microsoft Windows XP Professional" then $path = "C:\Documents and Settings\" $path2 = "\Local Settings\Application Data\Google\Chrome\Application\" ElseIf $opsys = "Microsoft Windows 7 Enterprise " then $path = "C:\Users\" $path2 = "\AppData\Local\Google\Chrome\Application\" EndIf Local $hDirList = FileFindFirstFile($path & "*.*") If $hDirList = -1 Then Return 0 Local $sDir = "", $hVerList = 0, $sVer = "" While 1 $sDir = FileFindNextFile($hDirList) If @error Then ExitLoop If StringInStr(FileGetAttrib($path & $sDir), "D") = 0 Then ContinueLoop ;not a folder If FileExists($path & $sDir & $path2) = 0 Then ContinueLoop $hVerList = FileFindFirstFile($path & $sDir & $path2 & "*.*") If $hVerList = -1 Then ContinueLoop While 1 $sVer = FileFindNextFile($hVerList) If @error Then ExitLoop If FileExists($path & $sDir & $path2 & $sVer & "\Installer\setup.exe") = 0 Then ContinueLoop RunWait($path & $sDir & $path2 & $sVer & "\Installer\setup.exe --uninstall --multi-install --chrome --force-uninstall") WEnd FileClose($hVerList) WEnd FileClose($hDirList) EndFunc ; --------------------------------------------------------------------------------------------------------------------------------------------------------------- ; *** Software removal using WMI Func WMIService($host) ;Connects to WMI Service $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2") If not IsObj($objWMIService) Then return 0 return $objWMIService EndFunc Func WMIQuery($objWMIService,$strWMIQuery) ;Perform WMI Query with Query String and Data Return Parameters $colItems = $objWMIService.ExecQuery($strWMIQuery) ;Execute query against WMI Service Object For $objItem in $colItems _FileWriteLog($logfile, "Uninstall " & $objitem.name) ;MsgBox(0,"Uninstall",$objitem.name) $objItem.Uninstall() Next return 1 EndFunc $objWMIService = WMIService("localhost") ;WMIService Object - Establish Connection If $objWMIService = 0 Then Exit $soft1 = WMIQuery($objWMIService,"Select * from Win32_Product Where Name like '%Google Chrome%'") ;Run WMI Query against WMIService Object If $objWMIService = 0 Then _FileWriteLog($logfile, "An error have occured") ;MsgBox(0,"Error","An error have occured") Exit(17) EndIf $objWMIService = 0 ; --------------------------------------------------------------------------------------------------------------------------------------------------------------- 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