diff --git a/ee/maintained-apps/inputs/winget/scripts/zen-browser_install.ps1 b/ee/maintained-apps/inputs/winget/scripts/zen-browser_install.ps1 new file mode 100644 index 0000000000..20dec41ee0 --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/zen-browser_install.ps1 @@ -0,0 +1,31 @@ +# Learn more about .exe install scripts: +# http://fleetdm.com/learn-more-about/exe-install-scripts +# +# Zen Browser ships a Mozilla/NSIS-based machine-scope installer. + +$exeFilePath = "${env:INSTALLER_PATH}" + +try { + +# Add arguments to install silently machine-wide. +# /S -> silent +# /PreventRebootRequired=true -> suppress reboot prompts +$processOptions = @{ + FilePath = "$exeFilePath" + ArgumentList = "/S /PreventRebootRequired=true" + 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 +} diff --git a/ee/maintained-apps/inputs/winget/scripts/zen-browser_uninstall.ps1 b/ee/maintained-apps/inputs/winget/scripts/zen-browser_uninstall.ps1 new file mode 100644 index 0000000000..d39e3c38e4 --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/zen-browser_uninstall.ps1 @@ -0,0 +1,91 @@ +# Fleet extracts name from installer (EXE) and saves it to PACKAGE_ID +# variable +$softwareName = "Zen Browser" + +# It is recommended to use exact software name here if possible to avoid +# uninstalling unintended software. +$softwareNameLike = "*$softwareName*" + +# Some uninstallers require a flag to run silently. +# Each uninstaller might use different argument (usually it's "/S" or "/s") +$uninstallArgs = "/S" + +$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 needed, add -notlike to the comparison to exclude certain similar + # software + if ($key.DisplayName -like $softwareNameLike) { + $foundUninstaller = $true + # Get the uninstall command. Some uninstallers do not include + # 'QuietUninstallString' and require a flag to run silently. + $uninstallCommand = if ($key.QuietUninstallString) { + $key.QuietUninstallString + } else { + $key.UninstallString + } + + # The uninstall command may contain command and args, like: + # "C:\Program Files\Software\uninstall.exe" --uninstall --silent + # 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 + } + if ($uninstallArgs -ne '') { + $processOptions.ArgumentList = "$uninstallArgs" + } + + # Start process and track exit code + $process = Start-Process @processOptions + $exitCode = $process.ExitCode + + # Prints the exit code + Write-Host "Uninstall exit code: $exitCode" + # Exit the loop once the software is found and uninstalled. + break + } +} + +if (-not $foundUninstaller) { + Write-Host "Uninstaller for '$softwareName' not found." + # Change exit code to 0 if you don't want to fail if uninstaller is not + # found. This could happen if program was already uninstalled. + $exitCode = 1 +} + +} catch { + Write-Host "Error: $_" + $exitCode = 1 +} + +Exit $exitCode diff --git a/ee/maintained-apps/inputs/winget/zen-browser.json b/ee/maintained-apps/inputs/winget/zen-browser.json new file mode 100644 index 0000000000..b3dca2fa1d --- /dev/null +++ b/ee/maintained-apps/inputs/winget/zen-browser.json @@ -0,0 +1,12 @@ +{ + "name": "Zen Browser", + "slug": "zen-browser/windows", + "package_identifier": "Zen-Team.Zen-Browser", + "unique_identifier": "Zen Browser (x64 en-US)", + "install_script_path": "ee/maintained-apps/inputs/winget/scripts/zen-browser_install.ps1", + "uninstall_script_path": "ee/maintained-apps/inputs/winget/scripts/zen-browser_uninstall.ps1", + "installer_arch": "x64", + "installer_type": "exe", + "installer_scope": "machine", + "default_categories": ["Browsers"] +} diff --git a/ee/maintained-apps/outputs/apps.json b/ee/maintained-apps/outputs/apps.json index d0a87de06d..d372e8ae3c 100644 --- a/ee/maintained-apps/outputs/apps.json +++ b/ee/maintained-apps/outputs/apps.json @@ -2864,6 +2864,13 @@ "unique_identifier": "Zed", "description": "Zed is a multiplayer code editor." }, + { + "name": "Zen Browser", + "slug": "zen-browser/windows", + "platform": "windows", + "unique_identifier": "Zen Browser (x64 en-US)", + "description": "Zen Browser is a Gecko based web browser." + }, { "name": "Zen Browser", "slug": "zen/darwin", diff --git a/ee/maintained-apps/outputs/zen-browser/windows.json b/ee/maintained-apps/outputs/zen-browser/windows.json new file mode 100644 index 0000000000..a5c2ca488f --- /dev/null +++ b/ee/maintained-apps/outputs/zen-browser/windows.json @@ -0,0 +1,22 @@ +{ + "versions": [ + { + "version": "1.20b", + "queries": { + "exists": "SELECT 1 FROM programs WHERE name = 'Zen Browser (x64 en-US)' AND publisher = 'Zen OSS Team';", + "patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM programs WHERE name = 'Zen Browser (x64 en-US)' AND publisher = 'Zen OSS Team' AND version_compare(version, '1.20b') < 0);" + }, + "installer_url": "https://github.com/zen-browser/desktop/releases/download/1.20b/zen.installer.exe", + "install_script_ref": "b813a9e0", + "uninstall_script_ref": "0361ed80", + "sha256": "cc09438f2fb028b8a3c121249e9d36715a168d559e5ea3a15e8653e781f63d12", + "default_categories": [ + "Browsers" + ] + } + ], + "refs": { + "0361ed80": "# Fleet extracts name from installer (EXE) and saves it to PACKAGE_ID\n# variable\n$softwareName = \"Zen Browser\"\n\n# It is recommended to use exact software name here if possible to avoid\n# uninstalling unintended software.\n$softwareNameLike = \"*$softwareName*\"\n\n# Some uninstallers require a flag to run silently.\n# Each uninstaller might use different argument (usually it's \"/S\" or \"/s\")\n$uninstallArgs = \"/S\"\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\nforeach ($key in $uninstallKeys) {\n # If needed, add -notlike to the comparison to exclude certain similar\n # software\n if ($key.DisplayName -like $softwareNameLike) {\n $foundUninstaller = $true\n # Get the uninstall command. Some uninstallers do not include\n # 'QuietUninstallString' and require a flag to run silently.\n $uninstallCommand = if ($key.QuietUninstallString) {\n $key.QuietUninstallString\n } else {\n $key.UninstallString\n }\n\n # The uninstall command may contain command and args, like:\n # \"C:\\Program Files\\Software\\uninstall.exe\" --uninstall --silent\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 }\n if ($uninstallArgs -ne '') {\n $processOptions.ArgumentList = \"$uninstallArgs\"\n }\n\n # Start process and track exit code\n $process = Start-Process @processOptions\n $exitCode = $process.ExitCode\n\n # Prints the exit code\n Write-Host \"Uninstall exit code: $exitCode\"\n # Exit the loop once the software is found and uninstalled.\n break\n }\n}\n\nif (-not $foundUninstaller) {\n Write-Host \"Uninstaller for '$softwareName' not found.\"\n # Change exit code to 0 if you don't want to fail if uninstaller is not\n # found. This could happen if program was already uninstalled.\n $exitCode = 1\n}\n\n} catch {\n Write-Host \"Error: $_\"\n $exitCode = 1\n}\n\nExit $exitCode\n", + "b813a9e0": "# Learn more about .exe install scripts:\n# http://fleetdm.com/learn-more-about/exe-install-scripts\n#\n# Zen Browser ships a Mozilla/NSIS-based machine-scope installer.\n\n$exeFilePath = \"${env:INSTALLER_PATH}\"\n\ntry {\n\n# Add arguments to install silently machine-wide.\n# /S -> silent\n# /PreventRebootRequired=true -> suppress reboot prompts\n$processOptions = @{\n FilePath = \"$exeFilePath\"\n ArgumentList = \"/S /PreventRebootRequired=true\"\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}\n" + } +}