asp.net打开本地exe文件 在本地访问服务器上部署的网页,点击网页上的按钮,打开本机上的exe文件,求助! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Process p = new Process(); p.StartInfo.FileName = @"c:\a.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.Start(); StreamReader sr = p.StandardOutput; s = sr.ReadToEnd(); p.WaitForExit(); p.Close();这样做,有安全问题,可能部署在iis会报错。 这样做是打开本机上的exe文件,不会是打开服务器上的吧。 上面的代码是C#代码,是运行在Server的,因而是执行Server的exe。如果要在网页上,点一个button,或者一个超链接,让其自动执行某一个程序,可以考虑 迅雷 下载的方式,在ie点一个下载链接,会自动启动迅雷,在firefox中,它会自动提示这种方式,不是直接去执行每个exe,而是在windows中注册一种链接类型,如迅雷的是 thunder://...... 这种方法挺好,但是具体怎么实现呢,我就想打开本机上的exe文件。 <script type="text/javascript"> <!-- function runExecutable() { var executableFullPath = 'F:\\ZK\\DownLoadFile\\YodaoDict.exe'; try { var shellActiveXObject = new ActiveXObject("WScript.Shell"); if ( !shellActiveXObject ) { alert('Could not get reference to WScript.Shell'); return; } shellActiveXObject.Run(executableFullPath, 1, false); shellActiveXObject = null; } catch (errorObject) { alert('Error:\n' + errorObject.message); } } // --> </script> <input type="button" onclick="runExecutable()" value="打开客户端程序"> 楼主使用js吧,可以打开客户端的,使用后台不可能,因为运行在服务器上,打开也只是打开的服务器上的 出现错误:Error:Automation 服务器不能创建对象 OK了,谢谢!用JS的确解决了 但发布到IIS上从局域网其他的电脑用ip访问又有问题是怎么回事啊?超急啊 asp.net用户控件 关于Ajax加载ResponseXML含特殊字符的问题,在线等 100分跪求报表控件。 一次错误导致网站只定向一个页面 如何确定excel中某列是否为数字类型的数据? 怎样在asp.net中实现在线编辑Excel文件?分不够在加,急急急急急急急急! 自己做的经验网,请各位看看,来者有分。 textbox输入数字的问题,求教 如何打印页面? 急!! CrystalReport.rpt中如何使用参数?中的text 怎样从别的页面得到值? 存储过程异常问题 aspxgridview模板列计算用来统计总价的问题
Process p = new Process(); p.StartInfo.FileName = @"c:\a.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start(); StreamReader sr = p.StandardOutput;
s = sr.ReadToEnd(); p.WaitForExit();
p.Close();
这样做,有安全问题,可能部署在iis会报错。
这样做是打开本机上的exe文件,不会是打开服务器上的吧。
<script type="text/javascript">
<!--
function runExecutable()
{
var executableFullPath = 'F:\\ZK\\DownLoadFile\\YodaoDict.exe'; try
{
var shellActiveXObject = new ActiveXObject("WScript.Shell"); if ( !shellActiveXObject )
{
alert('Could not get reference to WScript.Shell');
return;
} shellActiveXObject.Run(executableFullPath, 1, false);
shellActiveXObject = null;
}
catch (errorObject)
{
alert('Error:\n' + errorObject.message);
}
}
// -->
</script>
<input type="button" onclick="runExecutable()" value="打开客户端程序">
楼主使用js吧,可以打开客户端的,使用后台不可能,因为运行在服务器上,打开也只是打开的服务器上的
Error:
Automation 服务器不能创建对象
但发布到IIS上从局域网其他的电脑用ip访问又有问题是怎么回事啊?超急啊