Disable the UltraVNC System Tray Icon

This custom script disables the UltraVNC Tray Icon on the user's machine.

PowerShell Script

The UltraVNC System Tray Icon can be disabled by using a custom PowerShell script.

The following script is the Disable UltraVNC Tray Icon sample PowerShell script. Copy it and save it as a .ps1 file. For further information on hosting this script see Quick Guide to Self-Hosting Custom Scripts.

Disable UltraVNC Tray Icon Script

This script disables the UltraVNC Tray Icon on the computer it is run on.

circle-info

Note: Once this script is run, you will need to log off the current user session for the changes to come into effect.

# How to use this script
# HideUVNCTrayIcon.ps1 <Download_URL>  

param(
    [string]$URL,
    [string]$filename
)

$ScriptRoot = $PSScriptRoot
if ([string]::IsNullOrEmpty($ScriptRoot)) {
    $ScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}

$LogDir = "$ScriptRoot"
$LogFile = "$LogDir\HideUVNCTrayIcon.Log"
$ERROR_SUCCESS = 0
$ERROR_FAILED = 1
$ERROR_EXCEPTION_OCCURED = -1
$DownloadPath = "$ScriptRoot\"


$ERROR_PS_VER_LOWER = 20008
$versionMinimum = [Version]'3.0.99999.999'
Function ExitIfPSVersionLower {

    Log -logstring ("Info: PowerShell version is: " + $PSVersionTable.PSVersion)

    if ($versionMinimum -gt $PSVersionTable.PSVersion) {
        Log -logstring "Error: This script requires minimun PowerShell version: $versionMinimum"
        Exit $ERROR_PS_VER_LOWER
    }
}

Function CreateLogDir {
    If (!(Test-Path $LogDir)) {
        mkdir $LogDir | out-null
    }
}
Function Log {
    param(
        [Parameter(Mandatory = $true)][string]$logstring
    )

    $Logtime = Get-Date -Format "dd/MM/yyyy HH:mm:ss:fff"
    $logToWrite = "{$Logtime[PID:$PID]} : $logstring"
    Write-Host($logToWrite)
    Add-content $LogFile -value ($logToWrite)            
}

trap {
    Log -logstring "Exception occured in HideUVNCTrayIcon Script"
    $message = $Error[0].Exception.Message
    if ($message) {
        Log -logstring "EXCEPTION: $message"
    }

    Log -logstring "Exit from HideUVNCTrayIcon Script With Exitcode=$ERROR_EXCEPTION_OCCURED `r`n`r`n"
    exit $ERROR_EXCEPTION_OCCURED
}

function DownloadFile {

    if ([string]::IsNullOrEmpty($URL)) {
        Log -logstring "Error: file URL is not specified"
        $DownloadPath = ""
        return $DownloadPath
    }

    Log -logstring  "Download URL: $URL"
    
    #[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls11

    #Log -logstring "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls11"

    if ([string]::IsNullOrEmpty($filename)) {
        $filename = "HideUVNCTrayIcon.exe" 
    }

    $DownloadPath = ($DownloadPath + $filename)
    Log -logstring  "Download Path: $DownloadPath"
    Invoke-WebRequest -Uri $URL -OutFile $DownloadPath -UseBasicParsing

    if (!(Test-Path $DownloadPath)) {
        Log -logstring ("Error: Failed to download file. Path: " + $DownloadPath)
        $DownloadPath = ""
    } 

    return $DownloadPath
}

try {
    Push-Location $ScriptRoot
    # Create Log directory
    CreateLogDir
    Log -logstring "Inside HideUVNCTrayIcon Script"
    ExitIfPSVersionLower

    $DownloadPath = DownloadFile
    if (![string]::IsNullOrEmpty($DownloadPath)) {
        Log -logstring "Download Success: $DownloadPath"
        $ReturnValue = $ERROR_SUCCESS

        # Hide Tray Icon
        & $DownloadPath 1

        #Show Tray Icon
        # & $DownloadPath 0
    }
    else {
        Log -logstring "Download Failed"
        $ReturnValue = $ERROR_FAILED
    }
    Log -logstring "Exit from HideUVNCTrayIcon Script with Exitcode = $ReturnValue `r`n`r`n"
    Exit $ReturnValue
}
finally {
    Pop-Location
}

Custom Script Settings

The table below outlines all the fields that need to be set when creating this custom script.

circle-info

For a detailed guide, refer to Create a Disable UltraVNC Tray Icon Script.

Field

Value

Name

Disable UltraVNC Tray Icon

Type

PowerShell

Run As

System Account or Specified User Account

Create a Disable UltraVNC System Tray Icon Custom Script

Create a Custom Script

1. Select the Control Grid tab on the top menu bar.

2. Navigate to the Applications tab.

3. Click CUSTOM SCRIPT.

4. Select Create Custom Script.

5. Enter a Name for the script, Disable UltraVNC Tray Icon in this example. Use any name you'd like to use.

Creating a Custom Script for Disable UltraVNC Tray Icon

6. Enter the URL that points to the location where the script is being hosted, http://faronics.org/proservices/HideUVNCTrayIcon.ps1arrow-up-right in this example. You might need to download this file and host it on a link that is whitelisted in your firewall.

circle-info

Best Practice is to download the sample script and self-host it. You can do this for free with GitHub. See the Quick Guide to Self-Hosting Custom Scripts for more information.

7. Select the script type: Powershell.

8. Command Line: Enter the path to the exe file inside double-quotes "http://faronics.org/proservices/HideUVNCTrayIcon.exearrow-up-right" .

circle-info

The double-quotes " " are required around the command line parameter.

9. Select the account to Run As; either System Account or Specified User Account.

10. Click SAVE TO GRID.

circle-info

Once saved, the script can be pushed to an individual computer or groups of computers. It can also be scheduled using a Policy.

For a guide on how to run your Custom Script, see Pushing the Script.

circle-check

Last updated