How to remotely install UltraVNC server with PowerShell

Adam Bertram

Adam Bertram

Read more posts by this author.

VNC is one of the most popular remote desktop control products out there. It’s free and comes in many different flavors that administrators can pick from. In this post, we’re going to cover how to silently install UltraVNC, a flavor of VNC, on Windows.

If you’re a desktop administrator, there may have been a time in your career where you needed to connect to an UltraVNC server running on a user’s desktop to find that it was not installed. At that point, you might have talked the user through installing the UltraVNC server from a file share somewhere on the network. This takes time and resources.

It’s much better to automate this process and remotely install the UltraVNC server remotely with no user interaction at all! We can build a PowerShell script to do just that that allows you to remotely install UltraVNC server to as many computers as you need.

Finding UltraVNC silent install switches

Before we get too far, we’ll first need to figure out the switches required to make the install silent. Depending on the software, this might be an easy or incredibly frustrating experience.

To silently install UltraVNC server on a Windows machine, you’ll first need to create an INF file. The INF file is like an answer file providing all of the installation information the UltraVNC server needs.

You create this INF file by performing a typical install of UltraVNC on a single machine. Instead of simply launching the installer, you’ll use the /savinf which and provide the location of the INF file as shown below.

setup.exe /saveinf="C:\silentinstall.inf"

The example above will save a file called silentinstall.inf to the root of you C drive.

Next, you need to figure out how to use this answer file when installing UltraVNC on another computer. This is possible using the /loadinf switch and passing the file name in the same manner.

setup.exe /loadinf="C:\silentinstall.inf"

This works but doesn’t make the install completely silent like you need. To do that, you’ll need to add another switch to this; /verysilent.

setup.exe /verysilent /loadinf="C:\silentinstall.inf"

When executed, this syntax will silently install UltraVNC with all of the same answers I initially provided manually saved in the INF file.

Setting up remote install capability

We now have the ability to silently install this software on a machine. However, we have no way to do this to remote computers. As is, you have to manually copy the setup.exe file and the INF file to any computer you’d like to remotely install this on. This is unacceptable! Let’s automate all of this with a PowerShell function.

Since you’ve already got everything necessary to perform the install locally, you’ll now need to figure out first where you’re going to store the setup.exe file and the INF file. These files need to be accessible to every computer you’ll be installing UltraVNC to. You’ll be providing these files on a common file share to deliver those bits to remote computers.

Because you’ll probably need to reference the installer bits over and over again, it’s a good idea to place them on a file share somewhere on the network. I’ll put them on a share called ToolShare on my MEMBERSRV1 server. Below is where I’m starting to build a deployment PowerShell script.

$InstallerFolder = '\\MEMBERSRV1\ToolShare\VNC'

Next, you’ll need to copy the setup.exe and the INF file to remote computers on demand. To do this, use Copy-Item to do a simple file copy of the entire VNC folder. Below I’m copying the contents of my installer folder to the root of the C drive on the remote computer.

$ClientName = 'MYCLIENT'
Copy-Item -Path $InstallerFolder -Destination \\$ClientName\c$ -Recurse

Next, I’ll need to invoke the install remotely. PowerShell remoting is an excellent way to make this happen. I’ll use the Invoke-Command command to remotely execute the silent install from my computer. To do this, I’ll first need to wrap the command I need to run in a script block.

$scriptBlock = {
    Start-Process "C:\VNC\setup.exe" -Args "/verysilent/loadinf=`"C:\VNC\silentinstall.inf`"" -Wait -NoNewWindow

You can see you’re using the Start-Process cmdlet to kick off the installer on the remote computer and am passing the silent arguments as you came up with earlier.

Next, you’ll need to execute this script on the remote computer with the Invoke-Command command.

PS> Invoke-Command -ComputerName $ClientName -ScriptBlock $scriptBlock

This sends instructions to $ClientName to run the code inside of the script block. After this is complete, we’re done! UltraVNC is installed.

Cleaning up installer remnants

However, we’ve now left that C:\VNC folder on the remote computer. Let’s clean that up.

Remove-Item \\$ClientName\c$\VNC -Recurse

We’ve now installed UltraVNC and cleaned up any remnants we’ve left behind. If you’ve liked this approach, feel free to download the Deploy-VNC script from my Github repo. It encapsulates all of this code into a PowerShell function and adds some additional functionality to make remotely installing UltraVNC server on Windows machines a piece of cake!

Subscribe to Adam the Automator

Get the latest posts delivered right to your inbox

Looks like you're offline!