For those looking to deploy RealVNC via GPO, here's the easy solution I came up with yesterday. Just thought I'd share and save people the trouble I went through ...
This has been tested as a fresh install, upgrading from previous revisions of RealVNC v4.x.x and installing over the top of an existing v4.5.3. I'm sure it also works with other versions, but you'll need to test it first.
This should take no more than 20 mins to setup.
Instructions:
- Install RealVNC on a machine, configure it as required with relevant VNC/Windows password and security groups (if necessary).
- Export the following key to a file named vnc_settings.reg
HKEY_LOCAL_MACHINE\SOFTWARE\RealVNC\WinVNC4
- Copy the VNC setup .exe file and the above .reg file to a folder named VNC in the NETLOGON directory of your DC's, i.e. \\yourdomain.ext\NETLOGON\VNC
- Copy and paste the VBS code below into notepad.
- Amend lines 17-20 of the file to match your relevant NETLOGON\VNC path, setup file name, RealVNC version number and license key.
- Save the file with a .vbs extension
- Create a GPO and configure the relevant OU links and scope.
- Edit the GPO and add the .vbs file as a machine startup script.
Code:
' *********************************************************
' ** VBScript to deploy VNC
' **
' ** - Copies VNC setup and .reg file to local temp folder
' ** - Imports .reg file containing VNC settings
' ** - Runs setup file
' ** - Creates license key
' ** - Generates security key
' **
' ** Written by Andy Whittle, 28/07/10
' **
' *********************************************************
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject") ' Create the File System Object
strVNCSetupPath = "\\yourdomain.ext\netlogon\VNC\" ' Path to setup and .reg file on network share - Keep trailing slash
strVNCSetupFile = "vnc-E4_5_3-x86_x64_win32.exe" ' Full name of setup file with extension
strDeployVersion = "4.5.3" ' VNC version to be deployed
strVNCLicKey = "ABCDE-12345-FGHIJ-67890-KLMNO" ' VNC license key
strVNCRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\RealVNC\WinVNC4\" ' VNC registry key (HKLM) - Keep trailing slash
strVNCRegFile = "vnc_settings.reg" ' Full name of reg file with extension
strVNCInstallPath = """C:\Program Files\RealVNC\VNC4\" ' VNC installation path within 'Program Files' folder - Start with """ and end with trailing slash
strVNCConfigExe = "vncconfig.exe" ' Full name of VNC config program with extension
strTempDir = "C:\Temp\" ' Local temp folder to copy files to - Keep trailing slash
strStartMenuFolder = wshShell.Environment("PROCESS")("ALLUSERSPROFILE") _
& "\Start Menu\Programs\RealVNC" ' Path to VNC Start menu folder - NO trailing slash !
' ------------- DO NOT EDIT BELOW THIS LINE -------------
on error resume next
strCurrentVersion = wshShell.RegRead(strVNCRegKey & "Version") ' Check for existing VNC version
If strCurrentVersion = strDeployVersion Then ' If already has latest version ...
wscript.quit ' ... end script
End If
If Not objFSO.FolderExists(strTempDir) Then ' Check for local temp folder
objFSO.CreateFolder(strTempDir) ' Create local temp folder
End If
objFSO.CopyFile strVNCSetupPath & strVNCSetupFile, strTempDir, True ' Copy VNC setup file to local temp folder
objFSO.CopyFile strVNCSetupPath & strVNCRegFile, strTempDir, True ' Copy VNC reg settings file to local temp folder
strReturnCode = wshShell.run _
("reg import " & strTempDir & strVNCRegFile,0,false) ' Import reg settings
strReturnCode = wshShell.run _
(strTempDir & strVNCSetupFile _
& " /sp- /verysilent /norestart /COMPONENTS=WinVNC,WinVNC/VNCMirror",0,true) ' Run VNC setup file
strReturnCode = wshShell.run _
(strVNCInstallPath & strVNCConfigExe & """ -license " & strVNCLicKey,0,false) ' Generate license key
strReturnCode = wshShell.run _
(strVNCInstallPath & strVNCConfigExe & """ -service -generatekeys",0,false) ' Generate security key
wshShell.RegWrite strVNCRegKey & "Version", strDeployVersion, "REG_SZ" ' Write VNC version to registry
If objFSO.FolderExists(strStartMenuFolder) Then ' Check for VNC Start menu group
objFSO.DeleteFolder(strStartMenuFolder) ' Delete VNC Start menu group
End If
When the script is first executed, it will install the required version of RealVNC, regardless of existing installed version. A registry value named "Version" will then be added which the script will use to determine if the latest is already installed on subsequent runs and will quit if no installation is required.
The script is very quick to execute and install RealVNC and does so silently at startup. The .exe and .reg files are copied locally to speed up the process.
NB: Line 51 contains the install switches which can be amended to suit. We don't deploy the Viewer to all machines, although you might want to. Changing /VERYSILENT to /SILENT will display an installation progress screen, but will still be automated. Lines 59-61 exist to delete the VNC Start menu program group. This isn't necessary and the lines can be deleted or commented out with an apostrophe if you want to leave the shortcuts intact.
To upgrade in future, just copy the new setup execuable file to the NETLOGON\VNC directory and amend lines 18 and 19 of the .vbs file to reflect the new filename and version. That's it. The script will recognise the new version and deploy it as necessary.
As a side note, new VNC settings can be deployed using this script by changing the version number, e.g. change 4.5.3 on line 19 to 4.5.3_2. Again, you'll need to configure a machine with the new settings, then export the key to a .reg file and copy to NETLOGON\VNC. The script will recognise a change, even though it is the same version, and will reinstall VNC and import the new .reg file.
Enjoy !