VNC URL Protocol Handler

Here you will find help for frequently asked questions as well as for your specific question.

VNC URL Protocol Handler

Postby thewarden » 2011-11-08 15:58

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 ... 14(v=vs.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

Postby thewarden » 2011-11-08 16:18

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 ... 14(v=vs.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

Re: VNC URL Protocol Handler

Postby Spart » 2012-01-31 17:45

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.
Spart
 
Posts: 1
Joined: 2012-01-31 16:57

Re: VNC URL Protocol Handler

Postby thewarden » 2012-02-01 20:38

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.
User avatar
thewarden
 
Posts: 3
Joined: 2011-11-08 15:33

Re: VNC URL Protocol Handler

Postby matamba » 2012-03-28 03:48

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
matamba
 
Posts: 1
Joined: 2012-03-28 03:39

Re: VNC URL Protocol Handler

Postby peter » 2018-07-30 12:18

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/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)#registering-the-application-handling-the-custom-uri-scheme
https://ss64.com/nt/syntax-replace.html
https://stackoverflow.com/questions/5909012/windows-batch-script-launch-program-and-exit-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.
peter
 
Posts: 1
Joined: 2018-07-30 11:12


Return to General help

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

cron