2

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) {                        
                }
            });
        });

私はホームコントローラーメソッドを呼び出します。名前はOpenRDPWindowです

    public void OpenRDPWindow(string strIPAddress)
    {            
        Process objProcess = new Process();
        string exe = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.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を使用している私のシステムでは、正常に動作しており
    、サーバー側(C#)のコードをシステムに書き込んだため、IPアドレスに基づいてRDPウィンドウが開き
    ます...

  • プロジェクトをIISに展開した後、ユーザーがhrefリンクをクリックすると、RDP(mstsc.exe)がサーバーマシン(
    アプリケーションを展開する場所)で実行されていました。

  • しかし、ユーザーマシン(クライアント側)でRDPウィンドウを開く必要があります...

jqueryまたはjavascriptを使用してこれを解決するにはどうすればよいですか?(または)この問題を解決する他の方法はありますか?

前もって感謝します....@@@

4

2 に答える 2

5

この問題を解決するために、以下の手順に従いました。

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ウィンドウが開きます。

したがって、これはこの問題の解決策の1つのタイプです...

于 2012-07-26T12:40:51.623 に答える
1

jqueryまたはjavascriptを使用してこれを解決するにはどうすればよいですか?

ちょっと待ってください。クライアントコンピューターではなく、サーバーでプロセスを開いています。そのため、アプリケーションは機能しません。セキュリティ上の理由から、クライアントマシンでプロセスを開始することはできません。javascriptだけでこのタスクを達成することは、非常に難しいかもしれません。などの企業はそのLogMeInようなインターフェースを実装していますが、何年も遅れており、誰かがStackOverflowに投稿する数行のコードで達成したいと思うものではありません:-)

いくつかの可能性には、クライアント環境を制御できることを明らかに課すActiveXの使用が含まれます。もう1つの可能性は、FullTrustで実行されているSilverlight5 Out-Of-Browserアプリケーションを使用することです。これにより、クライアントでプロセスを開始できますが、最初のソリューションと同じ制限があることは明らかです。ActiveXは現在やや時代遅れのテクノロジです。

于 2012-07-05T09:46:54.243 に答える