我用C#为ASP.NET创建了一个页面来运行exe文件。我用下面的代码创建了一个按钮和一个事件:
ProcessStartInfo info = new ProcessStartInfo(@"C:\inetpub\wwwroot\Share\myfile.exe");
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardError = true;
info.RedirectStandardOutput = true;
//info.UserName = dialog.User;
info.UserName = "username";
string pass = "MY pass";
System.Security.SecureString secret = new System.Security.SecureString();
foreach (char c in pass)
secret.AppendChar(c);
info.Password = secret;
Process.Start(info);
我从编译器执行,它运行正常,但当我发布我的项目在localhost我没有任何行动。什么问题?
4条答案
按热度按时间qojgxg4l1#
您尝试了什么操作?可能是权限问题。默认情况下,您的网站不应执行外部可执行文件,因为这将带来严重的安全风险。也许有其他解决方案可以解决您的问题,但不涉及运行外部程序?
无论哪种方式,我强烈建议不要直接从你的网站运行可执行文件。如果你真的必须运行程序,也许你可以写一个简单的Windows服务,它可以接收消息(通过WCF?),然后在一个隔离的环境中执行你的程序。
e0bqpujr2#
为了执行(运行)www.example.com中的应用程序asp.net,我使用了以下方法:
1)请参阅其他网站上的代码:
或
2)在web.config的“assemblyIdentity”字段中,我添加了“模拟”参数,如下所示:
更改自
至
2)然后我在我的www.example.com中使用了该命令asp.net(可能也使用了asp2.0):
pbgvytdp3#
下面是我的示例代码,获取用户输入并执行一个可执行文件。
另一个例子
gv8xihay4#
你可以试试
或