2017-10-05 6 views
1

カスタムウィンドウショートカットを作成し、asp.mvcでダウンロードします。 特に、動的サーバーを引数としてリモートデスクトップショートカットをダウンロードできるようにします。ウィンドウのショートカットを作成してASP.NETでダウンロードしてください。

私はこの例をインターネットで見てきましたが、明らかにウェブアプリケーションのためのものではありませんでした。

public ActionResult Download() 
    { 
      WshShell wsh = new WshShell(); 
      IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut("/shorcut.lnk") as IWshRuntimeLibrary.IWshShortcut; 
      shortcut.Arguments = ""; 
      shortcut.TargetPath = "c:\\app\\myftp.exe"; 
      // not sure about what this is fro 
      shortcut.WindowStyle = 1; 
      shortcut.Description = "my shortcut description"; 
      shortcut.WorkingDirectory = "c:\\app"; 
      //shortcut.IconLocation = "specify icon location"; 
      shortcut.Save(); 

     return File("/shorcut.lnk", "application/octet-stream", "shorcut.lnk"); 
    } 

私はプレーンアクセスが拒否されました。それを行う別の方法がありますか?

+0

を働いていますか? –

答えて

0

私は間違った方向に問題を抱えていました。私はmstsc.exeのショートカットを行う必要はありませんでしたが、非常に単純なテキストをパラメータとして含む独自のrdpファイルを作成する必要がありました。

public ActionResult Download() 
     { 
      StringBuilder sb = new StringBuilder(); 
      string srv = "mysrv.myurl.com"; 
      sb.AppendFormat("full address:s:{0}", srv); 
      return File(Encoding.UTF8.GetBytes(sb.ToString()), 
      "text/plain", 
       string.Format("{0}.rdp", srv)); 
     } 

これは、ラインはあなたにアクセス拒否エラーを与えた

関連する問題