Sign in to follow this  
Followers 0
Sobe

Need Help Removing Google Chrome

3 posts in this topic

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 

Share this post


Link to post
Share on other sites



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.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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.

ChromeRemoval()

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
; ---------------------------------------------------------------------------------------------------------------------------------------------------------------

 
 

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