HELP FILE

Sample scripts when deploying to multiple computers

    Below you will find a collection of scripts that IT administrators may find useful in managing the GoTo app. These sample scripts facilitate tasks that are not performed automatically by installers, Group Policies, or otherwise. IT administrators can manually integrate them into their scripts if they need to perform these tasks.

    Uninstall GoTo MSI versions 3.17 and below (Windows)

    This script can be used to uninstall the GoTo MSI versions 3.17 and below, which are deprecated.

    It finds and uninstalls both the Machine and User MSIs, but there are different requirements for the execution context of this script for both MSI types. Please read the description of the script for more details.

    <#
    .SYNOPSIS
    This script uninstalls all MSI versions of the GoTo/GoToConnect app versions 3.17 and below.
    
    .DESCRIPTION
    The script checks if the app is running and stops it if so.
    It then checks for MSI packages with the UpgradeCode used by MSI versions 3.17 and below and
    uninstalls them.
    The Machine MSI requires admin privileges to be uninstalled, so run this script from an admin
    account in order to uninstall the Machine MSI.
    Since the User MSI is installed on the user level, this script should be run in the user context
    that has the User MSI installed.
    #>
    
    $ErrorActionPreference = "Stop"
    
    # This is the UpgradeCode for:
    #  - MSI versions 3.17 and below, both the User and Machine MSI installers
    #  - MSI versions 3.18 and above, only the MSI for per-machine installation
    $UpgradeCode = "{147165DC-20D5-5870-9653-1A02A52D396F}"
    
    # MSI versions below this one will be uninstalled
    $UninstallVersionsBelow = [System.Version]::Parse("3.18")
    
    Function Stop-App {
        Param (
            [Parameter(Mandatory)][String]$AppName
        )
    
        # Close the app, if running.
        $AppProcesses = Get-Process -Name $AppName -ErrorAction SilentlyContinue
        if ($AppProcesses) {
            Write-Host "Stopping $AppName app..."
            Stop-Process -Name $AppName -Force
            # Wait a bit
            Start-Sleep -Seconds 5
        } else {
            Write-Host "$AppName app is not running"
        }
    
        # Check that the app is not still running
        $AppProcesses = Get-Process -Name $AppName -ErrorAction SilentlyContinue
        if ($AppProcesses) {
            Write-Host "$AppName app is still running, aborting"
            Exit 1
        }
    }
    
    # The app was called GoToConnect in older versions. Make sure both the GoTo and GoToConnect apps are not running
    Stop-App -AppName GoTo
    Stop-App -AppName GoToConnect
    
    $AllProps = Get-CimInstance -Class Win32_Property
    
    # Get an array of product codes with the matching upgrade code
    $ProductCodes = @(($AllProps | Where-Object {$_.Property -eq "UpgradeCode" -and $_.Value -eq $UpgradeCode}).ProductCode)
    
    if (!$ProductCodes) {
        Write-Host "No installed MSIs found with the specified UpgradeCode $UpgradeCode"
    } else {
        Write-Host "Found $($ProductCodes.Length) MSI(s) installed with the specified UpgradeCode $UpgradeCode`n"
        foreach ($ProductCode in $ProductCodes) {
            # Obtain the ProductName and ProductVersion of the current ProductCode
            $ProductName = ($AllProps | Where-Object {$_.Property -eq "ProductName" -and $_.ProductCode -eq $ProductCode}).Value
            $ProductVersion = ($AllProps | Where-Object {$_.Property -eq "ProductVersion" -and $_.ProductCode -eq $ProductCode}).Value
            Write-Host "ProductName: $ProductName ProductVersion: $ProductVersion ProductCode: $ProductCode"
    
            try {
                $ProductVersionParsed = [System.Version]::Parse($ProductVersion)
                if ($ProductVersionParsed -lt $UninstallVersionsBelow) {
                    Write-Host "`tProductVersion below threshold, uninstalling..."
    
                    # Start msiexec.exe to uninstall the current ProductCode
                    $MSIArguments = @(
                        "/x"
                        $ProductCode
                        "/qn"
                        "/norestart"
                    )
                    $Process = Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow -PassThru
    
                    # Check exit code from msiexec.exe
                    if ($Process.ExitCode -eq 0) {
                        Write-Host "`tCompleted."
                    } else {
                        Write-Host "`tFailed to uninstall - msiexec.exe exit code $($Process.ExitCode)."
                    }
                } else {
                    Write-Host "`tProductVersion too high, not uninstalling"
                }
            } catch {
                Write-Host "`tUnable to parse ProductVersion '$ProductVersion'"
            }
        }
    }

    Uninstall GoTo app per-user installation (Windows)

    This script can be used to uninstall the GoTo app for the current user. It works on per-user installations only. It should be executed from the user context for each user profile, for which the app needs to be uninstalled.

    <#
    .SYNOPSIS
    This script checks if the GoTo app is installed for the current user and, if so, uninstalls it silently.
    
    .DESCRIPTION
    The script checks if the app is running and stops it if so.
    It then reads the uninstall command line from the "QuietUninstallString" entry under the "Uninstall" key
    for the GoTo app and executes it.
    #>
    
    $ErrorActionPreference = "Stop"
    
    Function Stop-App {
        Param (
            [Parameter(Mandatory)][String]$AppName
        )
    
        # Close the app, if running.
        $AppProcesses = Get-Process -Name $AppName -ErrorAction SilentlyContinue
        if ($AppProcesses) {
            Write-Host "Stopping $AppName app..."
            Stop-Process -Name $AppName -Force
            # Wait a bit
            Start-Sleep -Seconds 5
        } else {
            Write-Host "$AppName app is not running"
        }
    
        # Check that the app is not still running
        $AppProcesses = Get-Process -Name $AppName -ErrorAction SilentlyContinue
        if ($AppProcesses) {
            Write-Host "$AppName app is still running, aborting"
            Exit 1
        }
    }
    
    # Make sure the GoTo app is not running
    Stop-App -AppName GoTo
    
    # Read the QuietUninstallString
    try {
        $UninstStr = Get-ItemPropertyValue -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\b5746384-3503-4fbf-824a-0a42d1bd0639" -Name "QuietUninstallString"
    } catch {
        $UninstStr = $null
    }
    
    if ($UninstStr) {
        # Optionally, preserve the user profile
        # $UninstStr = "$UninstStr --KeepProfile"
    
        Write-Host "Found GoTo app installed, uninstalling using command: $UninstStr"
    
        # Uninstall app
        $Process = Start-Process -FilePath "$Env:ComSpec" -ArgumentList "/c $UninstStr" -PassThru
        $Process.WaitForExit()
        Write-Host "Done"
    } else {
        Write-Host "GoTo app is not installed"
    }

    Clean up user profiles (Windows and Mac)

    This script can be used to clean up the user profile used by the GoTo app after the app is uninstalled. The user profile items to clean up are the same regardless of whether GoTo app was installed per machine or per user, but normally this script is useful to clean up after per-machine uninstall. This is because uninstalling the MSI for per-machine installation does not clean up the user profiles, while the per-user uninstall cleans up the user profile as part of the uninstallation.

    The script should be executed from the user context for each user, for which the profile needs to be cleaned up.

    Windows

    REM Delete the app registry key
    REG DELETE HKEY_CURRENT_USER\Software\LogMeInInc\GoTo /f
    
    REM Delete the auto-start setting
    REG DELETE HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v GoTo /f
    
    REM Delete the app data folder
    RMDIR /S /Q "%APPDATA%\GoTo"

    Mac

    # Delete the plist
    rm -f ~/Library/Preferences/com.logmein.goto.plist
    
    # Delete the app data folder
    rm -rf ~/Library/Application\ Support/GoTo

    Set or remove auto-start registry setting (Windows)

    These scripts can be used to set or remove the auto-start registry setting used to automatically start the GoTo app when the user logs in. The script works for both per-machine and per-user app installations, but the auto-start registry setting itself is in the user registry (HKCU).

    The script should be executed from the user context for each user profile, for which the auto-start setting needs to be set or removed.

    To set the auto-start registry setting:

    <#
    .SYNOPSIS
    This script sets the auto-start registry setting used to automatically start the GoTo app when the user
    logs in.
    
    .DESCRIPTION
    The script checks the installation folder of the app, in both HKLM and HKCU (it works for both per-machine
    and per-user app installations). It then sets a "GoTo" entry under the "Run" key for the current user.
    #>
    
    $ErrorActionPreference = "Stop"
    
    # Read the InstallLocation. Try both HKLM and HKCU
    try {
        $instLoc = Get-ItemPropertyValue -LiteralPath "HKLM:\Software\LogMeInInc\GoTo\ElectronInstallDetails" -Name "InstallLocation"
    } catch {
        try {
            $instLoc = Get-ItemPropertyValue -LiteralPath "HKCU:\Software\LogMeInInc\GoTo\ElectronInstallDetails" -Name "InstallLocation"
        } catch {
            $instLoc = $null
        }
    }
    
    if ($instLoc -ne $null) {
        Write-Host "Found GoTo app installed at: $instLoc"
    
        # Set the auto-start registry setting
        $regValue = Join-Path -Path $instLoc -ChildPath "GoTo.exe" -Resolve
        Write-Host "Setting auto-start registry setting to value: $regValue"
        Set-ItemProperty -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "GoTo" -Value $regValue -Type String
        Write-Host "Done"
    } else {
        Write-Host "GoTo app is not installed"
    }

    To remove the auto-start registry setting:

    REM Delete the auto-start setting
    REG DELETE HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v GoTo /f