![](/img/trans.png)
[英]Process.Start is not working after hosting asp.net web application in IIS
[英]Start cmd process call in a .NET MVC web project on IIS web server (not working!)
嗨,軟件開發人員
所以我需要在我的 .NET MVC web 項目中啟動一個 CMD 進程。 這是我傳遞需要調用的命令的函數:
private void ExecuteCommandSync(string command)
{
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
// Hide the CMD window:
procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
// The following commands are needed to redirect the standard output.
procStartInfo.UseShellExecute = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit();
}
該命令調用一個程序,該程序啟動一個線性規划框架,該框架解決一個需要 20 秒才能完成的問題。
問題是調用此函數時沒有任何反應! 它在 IIS 之外工作正常,但在 IIS 中不行。 IIS Web 服務器在 Windows Server 2012 上運行。我的 Web 項目是從我們的本地網絡外部調用的,Web 服務器在其中運行,執行一些工作,調用我的同步方法並等待它完成並以返回結果結束作為 JSON 對象的調用。
這個問題表明它可能具有用戶權限。 在 Advanced Settings -> Identity 的 Web 項目的 Application Pools 中,我嘗試將ApplicaitonPoolIdentity更改為Local System (具有高權限),但沒有運氣(如此處所述)。
有沒有人對我如何解決這個問題有任何建議? 任何建議將不勝感激。
您必須在具有執行 exec 權限的用戶下運行項目池。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.