有没有办法使用jquery(客户端)打开RDP连接窗口?
我的jquery代码如下,
$(function () {
$(".RDPLink1").live('click', function () {
var IPAddress = $(this).attr('id'); // ip or name of computer to connect
$.ajax({
type: 'post',
cache: false,
data: { strIPAddress: IPAddress },
url: '<%=Url.Action("OpenRDPWindow","Home") %>',
success: function (data) {
}
});
});
我称Home控制器方法,名称是OpenRDPWindow,像
public void OpenRDPWindow(string strIPAddress)
{
Process objProcess = new Process();
string exe = Environment.ExpandEnvironmentVariables(@"%SystemRoot%system32mstsc.exe");
if (exe != null)
{
objProcess.StartInfo.FileName = exe;
objProcess.StartInfo.Arguments = "/v " + strIPAddress; // ip or name of computer to connect
objProcess.Start();
}
}
实际上我的需求是,当用户单击我页面中的href链接时,我们需要打开基于IP地址的RDP窗口...
在我使用VS2010的系统中,它工作正常,并且打开了RDP
基于 IPAddress 的窗口,因为我在服务器端编写了代码(C#)
到我的系统...在 IIS 中部署项目后,用户单击 href 链接,RDP(mstsc.exe)在服务器机器中运行(我在其中部署了我的
应用程序)。但是我需要在用户机器(客户端)中打开 RDP 窗口...
如何使用jquery或javascript解决这个问题?(或) 还有其他方法可以解决这个问题吗?
谢谢advance....@@@
我按照下面给出的步骤来解决这个问题,
1)Jquery代码是
$(function () {
$(".RDPLink1").live('click', function () {
var IPAddress = $(this).attr('id'); // ip or name of computer to connect
window.location.href="http://path/home/OpenRDP?address="+IPAddress ;
});
});
2)我创建了一个新的.aspx页面,并在GET方法(页面加载)中编写了下面给出的服务器端(C#)代码来解决此问题
[HttpGet]
public ActionResult OpenRDP()
{
string address = Request.QueryString["address"];
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}.rdp", address));
Response.Output.Write(string.Format(@"
screen mode id:i:2
session bpp:i:32
compression:i:1
keyboardhook:i:2
displayconnectionbar:i:1
disable wallpaper:i:1
disable full window drag:i:1
allow desktop composition:i:0
allow font smoothing:i:0
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:{0}
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:2
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
drivestoredirect:s:E:;
use multimon:i:0
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:2
redirectdirectx:i:1
use redirection server name:i:0", address));
Response.End();
return View();
}
它将从客户端的浏览器下载选项打开RDP窗口。
因此,这是此问题的一种解决方案...
如何使用jquery或javascript解决这个问题?
稍等片刻,您正在服务器上打开进程,而不是在客户端计算机上。这就是您的应用程序不起作用的原因。出于安全原因,您无法在客户端计算机上启动进程。仅通过javascript完成此任务可能非常具有挑战性。像LogMeIn
这样的公司已经实现了这样的接口,但背后还有多年的工作,而不是你可能希望在有人会在Stack Overflow上发布你的几行代码来实现的:-)
一些可能性包括使用 ActiveX,这显然强制要求您可以控制客户端环境。另一种可能性是使用在完全信任中运行的 Silverlight 5 浏览器外应用程序,它允许您在客户端上启动进程,但它显然具有与第一个解决方案相同的限制,只是 ActiveX 现在有点过时了。