Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://twitter.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

VNC URL Protocol Handler

Post Reply
User avatar
thewarden
Posts: 3
Joined: 2011-11-08 15:33

VNC URL Protocol Handler

Post by thewarden »

Hi, I would like to create a web page with links that one can click on to connect to various systems running UltraVNC Server using UltraVNC Viewer.
I'm on a Windows operating system but it would be a bonus on how to achieve this as well on a Linux system.

It is my understanding on Windows that one needs to add a VNC URL Protocol Handler , see registry example below. However when I merge this into my registry it only partially works. I get the vncviewer.exe to appear but it says "Invalid Server Specified" or it passes "VNC" as the server address and "192" as the port. I believe there needs to be some changes or plugin added to UltraVNC for this to work but I'm not positive.

Any help would be greatly appreciated.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\vnc]
@="URL:VNC Connection"
"URL Protocol"="http://www.uvnc.com/"
[HKEY_CLASSES_ROOT\vnc\DefaultIcon]
@="\"C:\\Program Files\\UltraVNC\\vncviewer.exe\",0"
[HKEY_CLASSES_ROOT\vnc\shell]
[HKEY_CLASSES_ROOT\vnc\shell\open]
[HKEY_CLASSES_ROOT\vnc\shell\open\command]
@="\"C:\\Program Files\\UltraVNC\\vncviewer.exe\" \"%1\""

Here are a few links on the topic that I've found, however they didn't help me resolve the problem.

http://msdn.microsoft.com/en-us/library ... s.85).aspx
http://retrohack.com/enabling-hyperlink ... n-windows/
http://community.spiceworks.com/scripts ... ol-handler
http://www.realvnc.com/pipermail/vnc-li ... 41408.html
http://forums.zyrion.com/showthread.php?t=147
http://kb.mozillazine.org/Register_protocol
User avatar
thewarden
Posts: 3
Joined: 2011-11-08 15:33

VNC URL Protocol Handler

Post by thewarden »

Hi, I want to be able to click on links within a browser that would open connections to systems running UltraVNC Server using UltraVNC Viewer. However I keep getting "Invalid server specified" or it takes the "VNC" as the server address and the takes "192" as the port instead of the server address.

It is my understanding to get this to work one has to add the following registry entry for the VNC protocol to work and possiblity a plugin or modification of UltraVNC to be able to handle the URI properly.

It would be a bonus to know how to achieve this on a Linux system as well but in my case this is all done on Windows XP to Windows 7 for now.

Any help or direction would be greatly appreciated.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\vnc]
@="URL:VNC Connection"
"URL Protocol"="http://www.uvnc.com/"
[HKEY_CLASSES_ROOT\vnc\DefaultIcon]
@="\"C:\\Program Files\\UltraVNC\\vncviewer.exe\",0"
[HKEY_CLASSES_ROOT\vnc\shell]
[HKEY_CLASSES_ROOT\vnc\shell\open]
[HKEY_CLASSES_ROOT\vnc\shell\open\command]
@="C:\\Program Files\\UltraVNC\\vncviewer.exe -connect %1"

I've found the following links on the topic, however they didn't help me resolve the issue.

http://msdn.microsoft.com/en-us/library ... s.85).aspx
http://retrohack.com/enabling-hyperlink ... n-windows/
http://community.spiceworks.com/scripts ... ol-handler
http://www.realvnc.com/pipermail/vnc-li ... 41408.html
http://forums.zyrion.com/showthread.php?t=147
http://kb.mozillazine.org/Register_protocol
Spart
Posts: 1
Joined: 2012-01-31 16:57

Re: VNC URL Protocol Handler

Post by Spart »

I was looking for a way to do this as well, and couldn't find a solution - so I rolled my own.

In my environment, we have about 50 PC's that need to be remotely viewed by supervisors for quality assurance purposes. They all have UltraVNC server installed with the same password set, so it's very easy to log into each of them.

The employees run a piece of software which tracks which IP address they're at and what they're doing (working, break, lunch, etc.) and puts that in a database. What I wanted to do was make a website using PHP that would let you click a hyperlink to view the employee's screen in the full VNC viewer (not some web-based substitute.) Unfortunately, UltraVNC does not handle URL's, so you have to make this work ad hoc.

The first thing I did was make a simple batch file that accepts "vnc:XXX.XXX.XXX.XXX" or "vnc:domain.name" as an input variable. It goes like this:

Code: Select all

ECHO OFF
SET S=%1
SET S=###%S%###
SET S=%S:"###=%
SET S=%S:###"=%
SET S=%S:###=%
SET S=%S:vnc:=%
start "VNCViewer" "C:\Program Files\UltraVNC\vncviewer.exe" -connect %S% -password PASSWORD -viewonly -notoolbar -disableclipboard -autoscaling -shared
The first six "SET" statements strip the enclosing quotes that are passed to the batch file, and also strip the "vnc:" prefix that will get passed to the batch file.

The first couple options for running vncviewer.exe in command line mode are -connect and -password. The %S% variable is the output of the SET statements, which will be the IP address or domain name you put after "vnc:" in your URLs. In my environment, all of the passwords are the same so I'm specifying the password in my batch file rather than passing the password through the URL. If you're doing the same thing, you'll want to replace "PASSWORD" with the password you're using. You might wish to adapt the batch file so that you can pass something like "vnc:password@XXX.XXX.XXX.XXX" or even "vnc:user:password@XXX.XXX.XXX.XXX". That will take some extra DOS-fu.

The rest of the options (-viewonly, -notoolbar, etc.) are specific to my environment. You can see the list of options available here: UltraVNC Viewer Commandline Parameters

Paste this script into Notepad and save it as "vnc-url-handler.bat" in a new directory in C:\ called "exe". You have to put it here if you don't want to modify the registry file that comes next. I use C:\exe as a catch-all for random batch files and programs that do ad hoc functions. Also note that your vncviewer.exe might be in "C:\Program Files (x86)\UltraVNC" if you've installed the 32 bit version of UltraVNC on a 64 bit Windows. Check to make sure first!

The next step is to modify your registry in order to pass "vnc:" URL's to the batch file you just created. Here is what I came up with:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\vnc]
"URL Protocol"=""
@="VNC: Protocol"

[HKEY_CLASSES_ROOT\vnc\shell]

[HKEY_CLASSES_ROOT\vnc\shell\open]

[HKEY_CLASSES_ROOT\vnc\shell\open\command]
@="\"C:\\exe\\vnc-url-handler.bat\" %1"
Copy this into Notepad and save it as "vnc-url-handler-enable.reg". Then double-click the file and select "Yes" on the message window that pops up.

All these registry entries do are pass "vnc:" URL's to the batch file you created. If you decided to save it somewhere else, you'll need to change the path in the last line.

That's about it! "vnc:XXX.XXX.XXX.XXX" URL's worked for me in IE9, Firefox, and Chrome after this. Each web browser has a security alert that you can disable on the first use.
User avatar
thewarden
Posts: 3
Joined: 2011-11-08 15:33

Re: VNC URL Protocol Handler

Post by thewarden »

Wow this is awesome. Thanks for the reply, the hard work and posting how you achieved this for everyone else to see. I will definitely have to try this out myself when I get some free time.
matamba
Posts: 1
Joined: 2012-03-28 03:39

Re: VNC URL Protocol Handler

Post by matamba »

Working with UltraVNC version: 1.0.8.2

This works for the most part.

For some reason I think it's VNC doing it.... it's putting a "//" at the beginning of the address it was connecting to. eg: VNC Server: //10.26.12.3/
Then I get the error: Failed to get server address

So I had to add "//" to your last variable line:
SET S=%S:vnc://=%

But again I think vncviewer is putting a "/" on the end of the address therefore it never connects.
Server address now looks like this: 10.26.12.3/

I'd like to know how to remove "/" from the end of the address, please.

FYI: It's not the browsers putting it on. Chrome and Firefox have vnc://10.26.12.3 as the address
peter
Posts: 1
Joined: 2018-07-30 11:12

Re: VNC URL Protocol Handler

Post by peter »

This thread may be old, but it still comes up on top in Google so I'd like to add my solutions for anyone still looking for this in 2018

TL:DR
1. Change your URLs from vnc:// to just vnc:
2. Replace your registry key with the one at the bottom (and delete your .bat file if you have one)
Works for me™ *
matamba wrote:... I think vncviewer is putting a "/" on the end of the address therefore it never connects.
Server address now looks like this: 10.26.12.3/

I'd like to know how to remove "/" from the end of the address, please.

FYI: It's not the browsers putting it on. Chrome and Firefox have vnc://10.26.12.3 as the address
First off, you need to change the URL to remove the two forward slashes. This prevents the training slash problem as well. And guess, what? It's not UltraVNC either. The trailing slash is already in the parameter %1. My educated guess is that any URL with the forward slashes is somehow normalized to include the trailing slash as well. Either by the browser's or Windows' URI handling part.

Second, I use a command line that does not require an external batch file. Also, this command closes the useless console window after launching UltraVNC.

Code: Select all

cmd.exe /V /C "set URL=%1& start "" "C:\Program Files (x86)\UltraVNC\vncviewer.exe" !URL:*:=!"
Either edit your existing command or install the entire key as provded at the bottom. You can then delete your .bat file if you have one.

Sources:
https://docs.microsoft.com/en-us/previo ... uri-scheme
https://ss64.com/nt/syntax-replace.html
https://stackoverflow.com/questions/590 ... it-console

Registry key:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\vnc]
@="URL:VNC Protocol"
"URL Protocol"="http://www.uvnc.com/"

[HKEY_CLASSES_ROOT\vnc\DefaultIcon]
@="C:\\Program Files (x86)\\UltraVNC\\vncviewer.exe,0"

[HKEY_CLASSES_ROOT\vnc\shell]

[HKEY_CLASSES_ROOT\vnc\shell\open]

[HKEY_CLASSES_ROOT\vnc\shell\open\command]
@="cmd.exe /V /C \"set URL=%1& start \"\" \"C:\\Program Files (x86)\\UltraVNC\\vncviewer.exe\" !URL:*:=!\""
*Works for me on Windows 10 with Chrome 68 and UltraVNC Viewer 1.2.1.2. Your mileage may vary.
VMP_user25
Posts: 1
Joined: 2020-02-10 20:44

Re: VNC URL Protocol Handler

Post by VMP_user25 »

For those looking for more info on x64 machines:

VNC url handler:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\vnc]
@="URL:VNC Protocol"
"URL Protocol"="http://www.uvnc.com/"

[HKEY_CLASSES_ROOT\vnc\DefaultIcon]

[HKEY_CLASSES_ROOT\vnc\shell]

[HKEY_CLASSES_ROOT\vnc\shell\open]

[HKEY_CLASSES_ROOT\vnc\shell\open\command]
@="cmd.exe /V /C \"set URL=%1& start \"\" \"C:\\Program Files\\uvnc bvba\\UltraVNC\\vncviewer.exe\" !URL:*://=!\""
Chrome bypass protocol prompt.

Having the url handlers in place is OK but Chrome will prompt the user each time they click on a url unless we bypass the prompt by adding the protocols into the protocol whitelist.

VNC bypass protocol prompt:

Code: Select all

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\URLWhitelist]
"1201"="vnc:*"
srhoades64
Posts: 1
Joined: 2020-07-28 07:20

Re: VNC URL Protocol Handler

Post by srhoades64 »

I know this is an old thread, but this is where I eventually found the answer, although for some reason, I had to modify it a bit.
The main issue I ran into is that my vncviewer.exe is located in C:\Program Files\UltraVNC

Entered as the above, it didn't work for me on a Windows 10 machine. After returning from backslash\single quote\double quote\escaped quote\no matching quote HELL, the key for me to make this work was to use 8.3 file notation (DOS Lives !).

Taken the knowledge from everyone above, here is my reg key:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\vnc]
@="\"URL:VNC Protocol\""
"URL Protocol"=""

[HKEY_CLASSES_ROOT\vnc\DefaultIcon]
@="\"C:\\Program Files\\UltraVNC\\vncviewer.exe,0\""

[HKEY_CLASSES_ROOT\vnc\shell]

[HKEY_CLASSES_ROOT\vnc\shell\open]

[HKEY_CLASSES_ROOT\vnc\shell\open\command]
@="cmd.exe /V /C \"set URL=%1& start \"\" \"C:\\PROGRA~1\\ULTRAVNC\\VNCVIE~1.EXE\" !URL:*:=!\""
Post Reply