如何从网页RDP

时间:2013-04-17 15:23:10

标签: web rdp

我正在尝试从我的网页打开到服务器的rdp会话。

<td><a href="file:///c:/Users/stegar06/Desktop/wtf.bat">testrdp</a></td>

.bat文件中只写了以下行: mstsc / v:emea-cirrus

该文件只是作为文本文件显示在我的Chrome浏览器中。所以网页只是加载,字面上说“mstsc / v:emea-cirrus”在顶部。如何启动远程桌面客户端并转到该地址?

我还尝试制作一个.rdp文件并引用那个href,它也只是显示为纯文本。 RDP文件是使用以下代码创建的:

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

3 个答案:

答案 0 :(得分:11)

您可以在服务器端创建.RDP文件,Windows应该与远程桌面关联,并强制浏览器下载它(而不是显示它)。在PHP中你会这样做:

$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();

我之前使用过这种技术并且效果很好。用户将单击该链接,系统将提示您保存或打开,如果他们单击打开,则远程桌面将使用指定的设置启动。

修改

.NET的示例,特别是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");
        }

答案 1 :(得分:2)

我可以建议使用基于浏览器的RDP客户端吗?如今,您有Guacamole FreeRDP-WebConnect(如果您有Linux服务器)或Myrtille用于Windows,那么您现在可以选择开源。还有商业软件,具有更多功能(取决于您的需求),如2X RDP客户端或LogMeIn。

答案 2 :(得分:1)

出于安全原因,您不能通过任何现代浏览器的链接运行批处理文件。

如果在VBScript中包装对批处理文件的调用并通过shell运行它,则可以使其正常工作。但是,您需要打开ActiveX权限才能让IE允许此操作。

有关如何执行此操作的示例,请参阅here