How do I create a VNC or RDP web link?

This is something that I've looked into and sorted recently, and I feel like sharing today 

If you manage a network, and have a web-based ticket or computer management system, it could be very handy to be able to start an RDP or VNC session using a hyperlink.

There are 2 approaches that I have found:

1) Create a new protocol handler for rdp:// or vnc://
2) Create .rdp and .vnc files on the fly

I've opted to go with solution 2, as #1 requires software installation on local computers to work, whereas #2 only requires a webserver with php set up (and it wouldn't be too difficult to translate to ASP/perl/or any other CGI language.

rdp.php:
PHP Code:
<?php 
$file 
'rdpconnect.txt'

if(!
file_exists($file)) 

   
// File doesn't exist, output error 
   
die('file not found'); 

else 

   if(isset(
$_GET) && array_key_exists("srv"$_GET) && preg_match("/^[A-Za-z0-9\.-][A-Za-z0-9\.-][A-Za-z0-9\.-]+$/i",$_GET["srv"])) 
   { 
      
$rdp_file file_get_contents($file); 
      
// Set headers 
      
header("Cache-Control: public"); 
      
header("Content-Description: File Transfer"); 
      
header("Content-Disposition: attachment; filename=" $_GET["srv"] . ".rdp"); 
      
header("Content-Type: text/plain"); 
      
header("Content-Transfer-Encoding: 8bit"); 

      echo 
str_ireplace("{SERVER_ADDRESS}"$_GET["srv"], $rdp_file); 
   } 
   else 
      die(
"You must specify a valid server name"); 

?>
rdpconnect.txt:
Code:
screen mode id:i:2
desktopwidth:i:1280
desktopheight:i:1024
session bpp:i:16
winposstr:s:0,1,305,203,1105,803
compression:i:1
keyboardhook:i:2
displayconnectionbar:i:1
disable wallpaper:i:0
disable full window drag:i:0
allow desktop composition:i:1
allow font smoothing:i:1
disable menu anims:i:0
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:{SERVER_ADDRESS}
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
devicestoredirect:s:*
drivestoredirect:s:*
vnc.php:
PHP Code:
<?php 
$file 
'vncconnect.txt'

if(!
file_exists($file)) 

   
// File doesn't exist, output error 
   
die('file not found'); 

else 

   if(isset(
$_GET) && array_key_exists("srv"$_GET) && preg_match("/^[A-Za-z0-9\.-][A-Za-z0-9\.-][A-Za-z0-9\.-]+$/i",$_GET["srv"])) 
   { 
      
$rdp_file file_get_contents($file); 
      
// Set headers 
      
header("Cache-Control: public"); 
      
header("Content-Description: File Transfer"); 
      
header("Content-Disposition: attachment; filename=" $_GET["srv"] . ".vnc"); 
      
header("Content-Type: text/plain"); 
      
header("Content-Transfer-Encoding: 8bit"); 

      echo 
str_ireplace("{SERVER_ADDRESS}"$_GET["srv"], $rdp_file); 
   } 
   else 
      die(
"You must specify a valid server name"); 

?>
vncconnect.txt
Code:
[connection]
host={SERVER_ADDRESS}
port=5900
[options]
use_encoding_0=1
use_encoding_1=1
use_encoding_2=1
use_encoding_3=0
use_encoding_4=1
use_encoding_5=1
use_encoding_6=0
use_encoding_7=0
use_encoding_8=0
use_encoding_9=0
use_encoding_10=0
use_encoding_11=0
use_encoding_12=0
use_encoding_13=0
use_encoding_14=0
use_encoding_15=0
use_encoding_16=1
preferred_encoding=5
restricted=0
viewonly=0
fullscreen=0
autoDetect=1
8bit=0
shared=1
swapmouse=0
belldeiconify=0
emulate3=1
emulate3timeout=100
emulate3fuzz=4
disableclipboard=0
localcursor=1
scale_num=1
scale_den=1
To call, simply link to rdp.php?srv=<computer name> or vnc.php?srv=<computer name>.

Examples:
HTML Code:
<a href="http://webserver/rdp.php?srv=webserver">RDP to webserver</a>
<a href="http://webserver/vnc.php?srv=webserver">VNC to webserver</a>
The scripts will initiate a download of a .rdp or .vnc file. Simply click "Open/Run" to open the connection.

Credits to http://www.perthstreetbikes.com/forum/f40/nerdy-tips-starting-vnc-rdp-hyperlink-125321/
  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

How do I change my remember password options in Google Chrome

Manage your website passwords This article applies to the Google Chrome browser on Windows,...

Change time is Gmail

Correct Your Gmail Time Zone To set your Gmail time zone: Click the gear in your Gmail's...

How to speed up Windows XP use at your own risk

Warning: occasionally people break their PC badly by using this list of suggestions. Usually...

How to run cmd in escalated mode with admin rights to modify firewall

a solution: runas /user:administrator@domainname.local cmd then in the resulting command...

How do I enable auto login in Windows

This article describes how to configure Windows to automate the logon...