
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");
}
?>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:*
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");
}
?>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
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>
Credits to http://www.perthstreetbikes.com/forum/f40/nerdy-tips-starting-vnc-rdp-hyperlink-125321/