diff --git a/ee/maintained-apps/inputs/winget/google-chrome.json b/ee/maintained-apps/inputs/winget/google-chrome.json index 111b363d7b..548216b373 100644 --- a/ee/maintained-apps/inputs/winget/google-chrome.json +++ b/ee/maintained-apps/inputs/winget/google-chrome.json @@ -1,11 +1,12 @@ { "name": "Google Chrome", "slug": "google-chrome/windows", - "package_identifier": "Google.Chrome", + "package_identifier": "Google.Chrome.EXE", "unique_identifier": "Google Chrome", + "install_script_path": "ee/maintained-apps/inputs/winget/scripts/google_chrome_install.ps1", + "uninstall_script_path": "ee/maintained-apps/inputs/winget/scripts/google_chrome_uninstall.ps1", "installer_arch": "x64", - "installer_type": "msi", + "installer_type": "exe", "installer_scope": "machine", - "ignore_hash": true, "default_categories": ["Browsers"] } diff --git a/ee/maintained-apps/inputs/winget/scripts/google_chrome_install.ps1 b/ee/maintained-apps/inputs/winget/scripts/google_chrome_install.ps1 new file mode 100644 index 0000000000..84f3a5070d --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/google_chrome_install.ps1 @@ -0,0 +1,23 @@ +$exeFilePath = "${env:INSTALLER_PATH}" + +try { + +$processOptions = @{ + FilePath = "$exeFilePath" + ArgumentList = "--do-not-launch-chrome --system-level" + PassThru = $true + Wait = $true +} + +# Start process and track exit code +$process = Start-Process @processOptions +$exitCode = $process.ExitCode + +# Prints the exit code +Write-Host "Install exit code: $exitCode" +Exit $exitCode + +} catch { + Write-Host "Error: $_" + Exit 1 +} \ No newline at end of file diff --git a/ee/maintained-apps/inputs/winget/scripts/google_chrome_uninstall.ps1 b/ee/maintained-apps/inputs/winget/scripts/google_chrome_uninstall.ps1 new file mode 100644 index 0000000000..3d82bc4181 --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/google_chrome_uninstall.ps1 @@ -0,0 +1,78 @@ +$softwareName = "Google Chrome" + +$uninstallArgs = "--uninstall" + +$expectedExitCodes = @(19, 20) + +$machineKey = ` + 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' +$machineKey32on64 = ` + 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' + +$exitCode = 0 + +try { + + [array]$uninstallKeys = Get-ChildItem ` + -Path @($machineKey, $machineKey32on64) ` + -ErrorAction SilentlyContinue | + ForEach-Object { Get-ItemProperty $_.PSPath } + + $foundUninstaller = $false + foreach ($key in $uninstallKeys) { + if ($key.DisplayName -eq $softwareName) { + $foundUninstaller = $true + # Get the uninstall command. + $uninstallCommand = if ($key.QuietUninstallString) { + $key.QuietUninstallString + } else { + $key.UninstallString + } + + # Split the command and args + $splitArgs = $uninstallCommand.Split('"') + if ($splitArgs.Length -gt 1) { + if ($splitArgs.Length -eq 3) { + $uninstallArgs = "$( $splitArgs[2] ) $uninstallArgs".Trim() + } elseif ($splitArgs.Length -gt 3) { + Throw ` + "Uninstall command contains multiple quoted strings. " + + "Please update the uninstall script.`n" + + "Uninstall command: $uninstallCommand" + } + $uninstallCommand = $splitArgs[1] + } + Write-Host "Uninstall command: $uninstallCommand" + Write-Host "Uninstall args: $uninstallArgs" + + $processOptions = @{ + FilePath = $uninstallCommand + PassThru = $true + Wait = $true + ArgumentList = "$uninstallArgs" + } + + # Start process and track exit code + $process = Start-Process @processOptions + $exitCode = $process.ExitCode + + Write-Host "Uninstall exit code: $exitCode" + break + } + } + + if (-not $foundUninstaller) { + Write-Host "Uninstaller for '$softwareName' not found." + Exit 1 + } + +} catch { + Write-Host "Error: $_" + Exit 1 +} + +if ($expectedExitCodes -contains $exitCode) { + $exitCode = 0 +} + +Exit $exitCode \ No newline at end of file diff --git a/ee/maintained-apps/outputs/google-chrome/windows.json b/ee/maintained-apps/outputs/google-chrome/windows.json index 4899005bc7..fd21f8c479 100644 --- a/ee/maintained-apps/outputs/google-chrome/windows.json +++ b/ee/maintained-apps/outputs/google-chrome/windows.json @@ -1,21 +1,21 @@ { "versions": [ { - "version": "138.0.7204.97", + "version": "138.0.7204.158", "queries": { "exists": "SELECT 1 FROM programs WHERE name = 'Google Chrome' AND publisher = 'Google LLC';" }, - "installer_url": "https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise64.msi", - "install_script_ref": "8959087b", - "uninstall_script_ref": "4836150f", - "sha256": "no_check", + "installer_url": "https://dl.google.com/release2/chrome/adoxq6yw64jzwswqufh3prv6wcra_138.0.7204.158/138.0.7204.158_chrome_installer_uncompressed.exe", + "install_script_ref": "a36a7752", + "uninstall_script_ref": "419aa758", + "sha256": "c04b9bef1a1a4ee74b238e47d45db20280480897a8a444aa225ed53c7c647ad7", "default_categories": [ "Browsers" ] } ], "refs": { - "4836150f": "# Fleet uninstalls app by finding all related product codes for the specified upgrade code\n$inst = New-Object -ComObject \"WindowsInstaller.Installer\"\nforeach ($product_code in $inst.RelatedProducts('{C1DFDF69-5945-32F2-A35E-EE94C99C7CF4}')) {\n msiexec /quiet /x $product_code\n}\n\nExit $LASTEXITCODE\n", - "8959087b": "$logFile = \"${env:TEMP}/fleet-install-software.log\"\n\ntry {\n\n$installProcess = Start-Process msiexec.exe `\n -ArgumentList \"/quiet /norestart /lv ${logFile} /i `\"${env:INSTALLER_PATH}`\"\" `\n -PassThru -Verb RunAs -Wait\n\nGet-Content $logFile -Tail 500\n\nExit $installProcess.ExitCode\n\n} catch {\n Write-Host \"Error: $_\"\n Exit 1\n}\n" + "419aa758": "$softwareName = \"Google Chrome\"\n\n$uninstallArgs = \"--uninstall\"\n\n$expectedExitCodes = @(19, 20)\n\n$machineKey = `\n 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n$machineKey32on64 = `\n 'HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n\n$exitCode = 0\n\ntry {\n\n [array]$uninstallKeys = Get-ChildItem `\n -Path @($machineKey, $machineKey32on64) `\n -ErrorAction SilentlyContinue |\n ForEach-Object { Get-ItemProperty $_.PSPath }\n\n $foundUninstaller = $false\n foreach ($key in $uninstallKeys) {\n if ($key.DisplayName -eq $softwareName) {\n $foundUninstaller = $true\n # Get the uninstall command.\n $uninstallCommand = if ($key.QuietUninstallString) {\n $key.QuietUninstallString\n } else {\n $key.UninstallString\n }\n\n # Split the command and args\n $splitArgs = $uninstallCommand.Split('\"')\n if ($splitArgs.Length -gt 1) {\n if ($splitArgs.Length -eq 3) {\n $uninstallArgs = \"$( $splitArgs[2] ) $uninstallArgs\".Trim()\n } elseif ($splitArgs.Length -gt 3) {\n Throw `\n \"Uninstall command contains multiple quoted strings. \" +\n \"Please update the uninstall script.`n\" +\n \"Uninstall command: $uninstallCommand\"\n }\n $uninstallCommand = $splitArgs[1]\n }\n Write-Host \"Uninstall command: $uninstallCommand\"\n Write-Host \"Uninstall args: $uninstallArgs\"\n\n $processOptions = @{\n FilePath = $uninstallCommand\n PassThru = $true\n Wait = $true\n ArgumentList = \"$uninstallArgs\"\n }\n\n # Start process and track exit code\n $process = Start-Process @processOptions\n $exitCode = $process.ExitCode\n\n Write-Host \"Uninstall exit code: $exitCode\"\n break\n }\n }\n\n if (-not $foundUninstaller) {\n Write-Host \"Uninstaller for '$softwareName' not found.\"\n Exit 1\n }\n\n} catch {\n Write-Host \"Error: $_\"\n Exit 1\n}\n\nif ($expectedExitCodes -contains $exitCode) {\n $exitCode = 0\n}\n\nExit $exitCode", + "a36a7752": "$exeFilePath = \"${env:INSTALLER_PATH}\"\n\ntry {\n\n$processOptions = @{\n FilePath = \"$exeFilePath\"\n ArgumentList = \"--do-not-launch-chrome --system-level\"\n PassThru = $true\n Wait = $true\n}\n \n# Start process and track exit code\n$process = Start-Process @processOptions\n$exitCode = $process.ExitCode\n\n# Prints the exit code\nWrite-Host \"Install exit code: $exitCode\"\nExit $exitCode\n\n} catch {\n Write-Host \"Error: $_\"\n Exit 1\n}" } } \ No newline at end of file