I'm trying to open an rdp session to a server from my web page.
<td><a href="file:///c:/Users/stegar06/Desktop/wtf.bat">testrdp</a></td>
The .bat file just has the following line written in it: mstsc /v:emea-cirrus
What happens is that the file just gets displayed in my chrome browser as a text file. So the web page just loads and literally says "mstsc /v:emea-cirrus" at the top. How can I get it to launch the remote desktop client and go to the address?
I have also tried making a .rdp file and referencing that is the href, which also just showed up as plain text. The RDP file was created using the following code:
screen mode id:i:2
desktopwidth:i:1436
desktopheight:i:925
session bpp:i:16
auto connect:i:1
full address:s:emea-orion
compression:i:1
keyboardhook:i:2
audiomode:i:2
redirectdrives:i:0
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:0
displayconnectionbar:i:1
alternate shell:s:
shell working directory:s:
disable wallpaper:i:1
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
bitmapcachepersistenable:i:1
winposstr:s:0,3,0,0,800,600
redirectclipboard:i:1
redirectposdevices:i:0
drivestoredirect:s:
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
allow desktop composition:i:0
allow font smoothing:i:0
disable cursor setting:i:0
gatewayhostname:s:
gatewayusagemethod:i:0
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
You can create the .RDP file on the server side, which Windows should associate with Remote Desktop, and force the browser to download it (instead of displaying it). In PHP you would do it like this:
$file = 'screen mode id:i:2
desktopwidth:i:1436
desktopheight:i:925
session bpp:i:16
auto connect:i:1
full address:s:emea-orion
compression:i:1
keyboardhook:i:2
audiomode:i:2
redirectdrives:i:0
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:0
displayconnectionbar:i:1
alternate shell:s:
shell working directory:s:
disable wallpaper:i:1
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
bitmapcachepersistenable:i:1
winposstr:s:0,3,0,0,800,600
redirectclipboard:i:1
redirectposdevices:i:0
drivestoredirect:s:
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
allow desktop composition:i:0
allow font smoothing:i:0
disable cursor setting:i:0
gatewayhostname:s:
gatewayusagemethod:i:0
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0';
header("Content-Disposition: attachment; filename=filename.rdp");
header("Content-Type: application/rdp");
print $file;
exit();
I've used this technique before and it has worked well. The user will click the link, be prompted to save or open, and if they click open Remote Desktop will launch with the settings specified.
Example for .NET in particular ASP.MVC
public FileResult RDP() {
MemoryStream memoryStream = new MemoryStream();
TextWriter tw = new StreamWriter(memoryStream);
tw.WriteLine("screen mode id:i:2");
tw.WriteLine("use multimon:i:0");
///The rest of the file
memoryStream.Position = 0;
return File(memoryStream, "application/rdp", "conenction.rdp");
}
May I suggest the use of a browser based RDP client? You have open source choice nowadays, from Guacamole FreeRDP-WebConnect if you have Linux servers or Myrtille for Windows. There are also commercial software, with more features (it depends on your needs) like 2X RDP client or LogMeIn.
For security reasons, you can't simply run a batch file via a link from any modern browser.
You can get this to work if you wrap the call to the batch file in a VBScript and run it via the shell. However, you'll need to open up your ActiveX permissions to have IE permit this.
For an example of how to do this, see here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With