如何从网页RDP

Ste*_*eve 7 rdp web

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

<td><a href="file:///c:/Users/stegar06/Desktop/wtf.bat">testrdp</a></td>
Run Code Online (Sandbox Code Playgroud)

.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
Run Code Online (Sandbox Code Playgroud)

Cha*_*ser 13

您可以在服务器端创建.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();
Run Code Online (Sandbox Code Playgroud)

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

编辑

.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");
        }
Run Code Online (Sandbox Code Playgroud)

  • 我希望你不介意,我为.NET添加了一个例子 - 我做了这个并且效果很好.提示是使用RDP,执行所有设置,然后在常规选项卡上单击选项和"另存为".复制所有设置.这很棒,因为您可以随时随地使用URL构建数据库或其他内容来构建RDP文件.实际上,这应该是答案! (4认同)

Pin*_*nyM 1

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

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

有关如何执行此操作的示例,请参见此处