[英]How can I get a program on a client machine to run from an ASP.NET page?
I have an app that I'm trying to run on an intranet. 我有一个应用程序,我试图在Intranet上运行。 On my machine it worked great (famous last words) but when I put it up to the server, it didn't work.
在我的机器上它工作得很好(着名的遗言)但是当我把它放到服务器上时,它没有用。 As soon as I saw the "the system cannot find the specified file" error, I figured it had to be something with trying to run a program that's on a client machine.
当我看到“系统找不到指定文件”错误时,我认为它必须是尝试运行客户端计算机上的程序。
Yes, it would be a security nightmare if any app in a browser could run an executable on a client machine. 是的,如果浏览器中的任何应用程序可以在客户端计算机上运行可执行文件,那将是一场安全噩梦。 Is this any different for intranet?
内联网有什么不同吗? The few computers it would run on all have the same version of IE and .NET that it will run on, and they all have the required .exe to run.
它将运行的几台计算机都具有相同版本的IE和.NET,它们将运行,并且它们都具有运行所需的.exe。
Here's an overview of the project: 以下是该项目的概述:
Can anyone help me out on how to do this (or at least let me know it's not feasible)? 任何人都可以帮我解决如何做到这一点(或者至少让我知道这是不可行的)?
一个想法:您可以注册协议处理程序以使用所需参数启动您的应用程序。
There are a couple of ways to do this. 有几种方法可以做到这一点。 One doesn't violate security (much).
一个人不违反安全(很多)。
You can download a file with a particular file type. 您可以下载具有特定文件类型的文件。 That file type can be associated to the client program, so after clicking "ok" to download the file, the client program would launch.
该文件类型可以与客户端程序关联,因此在单击“确定”下载文件后,客户端程序将启动。 The downloaded file may or may not contain some data like the id of some object.
下载的文件可能包含也可能不包含某些数据,如某些对象的ID。
The alternative would be to resort to ActiveX, which does have security implications. 另一种方法是使用ActiveX,它确实具有安全隐患。
If you put your site in the IE Trusted or Intranet zone, the following Javascript will work just fine. 如果您将您的网站放在IE Trusted或Intranet区域,以下Javascript将正常工作。 I use this one internally to link our PC support DB search to our remote screen control software:
我在内部使用这个将我们的PC支持数据库搜索链接到我们的远程屏幕控制软件:
<script type="text/javascript" language="javascript">
function runDameWare(strHostname, blControl) {
var objShell = new ActiveXObject("Wscript.Shell");
var strCommand = "C:\\Program Files\\Dameware\\dwrcc.exe -c: -h: -m:";
strCommand += strHostname;
if (blControl) {
strCommand += " -v:";
}
objShell.Exec(strCommand);
}
</script>
My understanding is that uploading the results of your work in the local program to the web server can be accomplished using the HttpWebRequest
class, as shown in this article: 我的理解是,可以使用
HttpWebRequest
类将本地程序中的工作结果上传到Web服务器,如本文所示:
http://forums.asp.net/p/1482778/3464854.aspx http://forums.asp.net/p/1482778/3464854.aspx
Edit: This is how I call the above function. 编辑:这是我如何调用上述功能。 Basically I'm just rendering a plain
<a>
element with the onclick
attribute. 基本上我只是用
onclick
属性渲染一个普通的<a>
元素。 There's probably a cleaner way to do it, but it works: 可能有一种更简洁的方法,但它有效:
Markup: 标记:
<asp:TemplateField>
<ItemTemplate>
<%# RenderDameWareLinks(Eval("ResourceName"))%>
</ItemTemplate>
</asp:TemplateField>
Code: 码:
Protected Function RenderDameWareLinks(ByVal strHostname As String) As String
Dim strFullLink As String = String.Empty
Dim strViewLink As String = String.Empty
strFullLink = "<a onclick=""runDameWare('" & strHostname & "', false);"">"
strFullLink &= "<img alt=""Connect using DameWare"" src=""Image/dameware1.gif"" style=""padding: 2px;"" />"
strFullLink &= "</a><br/>"
strViewLink = "<a onclick=""runDameWare('" & strHostname & "', true);"">"
strViewLink &= "<img alt=""Connect (View Only) using DameWare"" src=""Image/dameware2.gif"" style=""padding: 2px;"" />"
strViewLink &= "</a>"
Return strFullLink & strViewLink
End Function
由于机器已经需要安装这个“隐藏”程序,为什么不只是编写一个本机应用程序并安装它并让员工运行而不是你的Web应用程序?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.