[英]How to run .Bat file in asp.net,IIS
如何在 IIS 中啟動 XXX.bat 文件? 我想運行這個文件..當我在我的開發 PC 中執行它時它完美運行。 但是當我部署在 IIS 中時,它的工作和不執行.bat 文件
所以請指導我怎么做...我的代碼如下
\\
string exefile = ConfigurationManager.AppSettings["exefile"]; //exefile="D:\\XX\\xxx.bat"
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(exefile);
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardError = true;
System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);
\\
我會檢查安全性。
“托管” IIS 進程的用戶可能無權在 IIS 文件夾之外運行執行文件。
發布實際的錯誤消息也會有所幫助。 附帶說明一下,如果它的 Exepction 是 UnauthorizedAccessException 類型,那么它很可能是我上面描述的。
我遇到了這個問題,對我來說這是 bat 文件的位置。 它已將 bat 文件放在 Visual Studio 的解決方案下它自己的文件夾中,但這意味着 IIS 無法訪問它。 當我將 bat 文件移動到 wwwroot 文件夾時,一切都按預期工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.