[英]Using Webpage to run exe on Localhost
我正在尝试使用iis localhost上的网页来运行可执行文件,但该文件无法正常工作。 如果我使用Visual Studio运行网页,则效果很好。 我尝试更改可执行文件所在的文件夹的权限,以授予对DefaultAppPool的完全访问权限。 我尝试更改DefaultAppPool中的设置以启用32位应用程序,并且还将标识更改为LocalSystem。 我已允许IIS Admin Service与桌面进行交互。 这些都不起作用。
这就是我的代码。 任何帮助将不胜感激。
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int port = Convert.ToInt32(GridView1.SelectedRow.Cells[2].Text);
string ipaddress = GridView1.SelectedRow.Cells[3].Text;
string event_type = GridView1.SelectedRow.Cells[6].Text;
try
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.WorkingDirectory = @"C:\inetpub\wwwroot";
startInfo.FileName = Path.Combine(@"C:\inetpub\wwwroot", "ConsoleAppField.exe");
startInfo.Verb = "runas";
//MLHIDE
startInfo.Arguments = ipaddress + " " + port + " " + event_type;
startInfo.ErrorDialog = true;
Process process = Process.Start(startInfo);
process.WaitForExit();
//return process.ExitCode;
}
catch (Win32Exception ex)
{
}
catch (Exception ex)
{
//WriteLog(ex);
//return ErrorReturnInteger;
}
}
您可以通过使用Process.Start()并像这样传递参数来做到这一点,
Process.Start("C:\inetpub\wwwroot\ConsoleAppField.exe", ipaddress + " " + port + " " + event_type);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.