From e17ca439255750cfc181058a401e95fc3dc40bbf Mon Sep 17 00:00:00 2001 From: Tim Lee Date: Fri, 28 Mar 2025 17:15:26 -0400 Subject: [PATCH] Add teamviewer windows FMA (#27651) --- .../winget/scripts/teamviewer_install.ps1 | 29 +++++++++ .../winget/scripts/teamviewer_uninstall.ps1 | 63 +++++++++++++++++++ .../inputs/winget/teamviewer.json | 11 ++++ .../outputs/teamviewer/windows.json | 19 ++++++ 4 files changed, 122 insertions(+) create mode 100644 ee/maintained-apps/inputs/winget/scripts/teamviewer_install.ps1 create mode 100644 ee/maintained-apps/inputs/winget/scripts/teamviewer_uninstall.ps1 create mode 100644 ee/maintained-apps/inputs/winget/teamviewer.json create mode 100644 ee/maintained-apps/outputs/teamviewer/windows.json diff --git a/ee/maintained-apps/inputs/winget/scripts/teamviewer_install.ps1 b/ee/maintained-apps/inputs/winget/scripts/teamviewer_install.ps1 new file mode 100644 index 0000000000..f4e83b4de3 --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/teamviewer_install.ps1 @@ -0,0 +1,29 @@ +# Learn more about .exe install scripts: +# http://fleetdm.com/learn-more-about/exe-install-scripts + +$exeFilePath = "${env:INSTALLER_PATH}" + +try { + +# Add argument to install silently +# Argument to make install silent depends on installer, +# each installer might use different argument (usually it's "/S" or "/s") +$processOptions = @{ + FilePath = "$exeFilePath" + ArgumentList = "/S" + 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/teamviewer_uninstall.ps1 b/ee/maintained-apps/inputs/winget/scripts/teamviewer_uninstall.ps1 new file mode 100644 index 0000000000..e966274e32 --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/teamviewer_uninstall.ps1 @@ -0,0 +1,63 @@ +# Define acceptable/expected exit codes +$ExpectedExitCodes = @(0) + +# Uninstall Registry Key +$machineKey = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TeamViewer' + +# Additional uninstall args +$uninstallArgs = "/S" + +# Initialize exit code +$exitCode = 0 + +try { + $key = Get-ItemProperty -Path $machineKey -ErrorAction Stop + + # Get the uninstall command. Some uninstallers do not include 'QuietUninstallString' + $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.`nUninstall 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 uninstall process + $process = Start-Process @processOptions + $exitCode = $process.ExitCode + Write-Host "Uninstall exit code: $exitCode" + +} catch { + Write-Host "Error: $_" + $exitCode = 1 +} + +# Treat acceptable exit codes as success +if ($ExpectedExitCodes -contains $exitCode) { + Exit 0 +} else { + Exit $exitCode +} diff --git a/ee/maintained-apps/inputs/winget/teamviewer.json b/ee/maintained-apps/inputs/winget/teamviewer.json new file mode 100644 index 0000000000..1af91b0e5d --- /dev/null +++ b/ee/maintained-apps/inputs/winget/teamviewer.json @@ -0,0 +1,11 @@ +{ + "name": "TeamViewer", + "slug": "teamviewer/windows", + "package_identifier": "TeamViewer.TeamViewer", + "unique_identifier": "TeamViewer", + "install_script_path": "ee/maintained-apps/inputs/winget/scripts/teamviewer_install.ps1", + "uninstall_script_path": "ee/maintained-apps/inputs/winget/scripts/teamviewer_uninstall.ps1", + "installer_arch": "x64", + "installer_type": "exe", + "installer_scope": "machine" +} diff --git a/ee/maintained-apps/outputs/teamviewer/windows.json b/ee/maintained-apps/outputs/teamviewer/windows.json new file mode 100644 index 0000000000..4a797ce530 --- /dev/null +++ b/ee/maintained-apps/outputs/teamviewer/windows.json @@ -0,0 +1,19 @@ +{ + "versions": [ + { + "version": "15.64.3", + "queries": { + "exists": "SELECT 1 FROM programs WHERE name = 'TeamViewer' AND publisher = 'TeamViewer';" + }, + "installer_url": "https://download.teamviewer.com/download/version_15x/TeamViewer_Setup_x64_15.64.3.exe", + "unique_identifier": "TeamViewer", + "install_script_ref": "45f422bf", + "uninstall_script_ref": "390c83e7", + "sha256": "2a8aefd4f2e4a44c3f7c55caa35d61827e37392fe72726b9a980299f9199a230" + } + ], + "refs": { + "390c83e7": "# Define acceptable/expected exit codes\n$ExpectedExitCodes = @(0)\n\n# Uninstall Registry Key\n$machineKey = 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\TeamViewer'\n\n# Additional uninstall args\n$uninstallArgs = \"/S\"\n\n# Initialize exit code\n$exitCode = 0\n\ntry {\n $key = Get-ItemProperty -Path $machineKey -ErrorAction Stop\n\n # Get the uninstall command. Some uninstallers do not include 'QuietUninstallString'\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 \"Uninstall command contains multiple quoted strings. Please update the uninstall script.`nUninstall command: $uninstallCommand\"\n }\n $uninstallCommand = $splitArgs[1]\n }\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 uninstall process\n $process = Start-Process @processOptions\n $exitCode = $process.ExitCode\n Write-Host \"Uninstall exit code: $exitCode\"\n\n} catch {\n Write-Host \"Error: $_\"\n $exitCode = 1\n}\n\n# Treat acceptable exit codes as success\nif ($ExpectedExitCodes -contains $exitCode) {\n Exit 0\n} else {\n Exit $exitCode\n}\n", + "45f422bf": "# Learn more about .exe install scripts:\n# http://fleetdm.com/learn-more-about/exe-install-scripts\n\n$exeFilePath = \"${env:INSTALLER_PATH}\"\n\ntry {\n\n# Add argument to install silently\n# Argument to make install silent depends on installer,\n# each installer might use different argument (usually it's \"/S\" or \"/s\")\n$processOptions = @{\n FilePath = \"$exeFilePath\"\n ArgumentList = \"/S\"\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" + } +} \ No newline at end of file