0

A bit of context:

I have a website with links to VNCs for our team to use -- those VNC URLs are formatted like this:

vnc://000.000.0.0:5901

Most of our team uses Macbooks, and MacOS handles these urls by default to open Screen Sharing. However, one of our team members uses a PC, and needs to set up a custom url protocol.

Here's what we've tried so far

Added the following using the Registry Editor:

HKEY_CLASSES_ROOT/
  vnc/
    (Default)    "URL:vnc Protocol"
    URL Protocol ""
    shell/
      open/
        command/
          (Default) "C:\Program Files\RealVNC\VNC Viewer\vncviewer.exe" "%1"

This got us 99% of the way there -- clicking on the URL opens the app 'VNC Viewer', and passes the url. However, VNC Viewer fails to open this properly, because for some reason, it tries to open "vnc://000.000.0.0:5901/" (added a trailing / character).

The error I get is:

Invalid endpoint: port not correctly specified

What do I need to do to get it to remove/filter out the trailing "/" character?

Thank you!

References

How do I register a custom URL protocol in Windows? How do I create my own URL protocol? (e.g. so://...)

jonoh
  • 13
  • 2

2 Answers2

0

I wasn't able to isolate the source of the trailing slash (/) appended to the url. I read several articles that seemed to suggest the browser (I'm using Chrome, but same thing happened on Microsoft Edge) was adding this -- something about the DirectoryIndex.

Anyhow, I was able to put together a workaround by:

Creating a batch file to format the url

This batch file takes the url, and:

  1. Start & end quote marks -- The string passed was "vnc://000.000.0.0:0000/", and it removes the "vnc:// and /" from the string (using first 7 characters and last 2 characters)

  2. Calls VNC Viewer, passing the new formatted url as a parameter.

vnc-url-handler.bat

SET S=%1
SET S=%S:~7,-2%
call "C:\Program Files\RealVNC\VNC Viewer\vncviewer.exe" %S%
quit 0

You can create this on Notepad, and save it as the proper file format.

Modifying Registry Key to point to the Batch file, instead of my app

HKEY_CLASSES_ROOT/
  vnc/
    (Default)    "URL:vnc Protocol"
    URL Protocol ""
    shell/
      open/
        command/
          (Default) "path_to_vnc-url-handler.bat_here" "%1"

This worked in Windows 10, Chrome 83.

There will be a command prompt window opened each time it opens VNC Viewer, but you can close it (or it will close when you close your session of VNC Viewer). I didn't figure out how to do this yet, but low priority for me.

jonoh
  • 13
  • 2
0

Without batch file:

Windows Registry Editor Version 5.00

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

[HKEY_CLASSES_ROOT\vnc\shell\open\command]
@="cmd /V:ON /C set address=%1 && set address=!address:~6,-2! && \"C:\\Program Files\\uvnc bvba\\UltraVNC\\vncviewer.exe\" -connect !address!-notoolbar -nostatus -noauto -8greycolors"