需要在ASP.net服务器上执行* .exe

我目前的情况是,我需要执行一个exe文件(它会创build一个本地的.txt文件)在远程服务器上的IIS托pipe一个ASP.net/C# API。 我创build了一个本地用户(称为userA)作为pipe理员在远程服务器上运行Web服务,但未创build.txt文件。 我已经检查并授予userA必要的文件夹权限,并将用户添加到各个组中。 有趣的是,如果我在远程系统中以userA身份login,则exe会按预期执行。 如果我注销,那么它失败。 服务器是Win Server 2008与IIS 7.任何帮助将不胜感激谢谢。

更新:我已经解决了这个问题,并在SO上发布了相关问题的答案和几个链接。 总之,我需要在IIS应用程序池中设置“载入用户configuration文件”为真。

谢谢大家的贡献

更新:我设法解决这个问题多星期后。 谢谢大家的贡献。 显然,IIS默认不加载Windows用户配置文件。 因此,当作为不登录的其他用户运行时,他们的Windows配置文件必须由IIS加载。 在你的应用程序池的高级设置菜单中,有一个选项“加载窗口配置文件”,我只是改变了这个为真。 在以前的IIS版本中,默认设置为“true”。

有关相同的解决方案SO的相关问题:

1) ASP.NET中的安全异常和IIS 7.5中的“加载用户配置文件”选项

2) 在IIS7上运行一个asp.net web应用程序项目会抛出异常

3) 新部署System.Web.AspNetHostingPermission异常

另外4) http://geekswithblogs.net/ProjectLawson/archive/2009/05/05/iis-system.web.aspnethostingpermission-exception-on-windows-7-rc.aspx

你可以使用Process.Start

Process process = new Process(); process.StartInfo.FileName = "CVS.exe"; process.StartInfo.Arguments = "if any"; process.Start(); 

在asp.net中还有一个关于正在运行进程的文章:

http://weblogs.asp.net/hernandl/archive/2005/12/02/startprocessasuser.aspx

提供用户凭证

简而言之,它说你必须重定向过程,像这样的代码:

 ProcessStartInfo info = new ProcessStartInfo("cmd.exe"); info.UseShellExecute = false; info.RedirectStandardInput = true; info.RedirectStandardError = true; info.RedirectStandardOutput = true; info.UserName = dialog.User; // see the link mentioned at the top info.Password = dialog.Password; using (Process install = Process.Start(info)) { string output = install.StandardOutput.ReadToEnd(); install.WaitForExit(); // Do something with you output data Console.WriteLine(output); }