![](/img/trans.png)
[英]Update C# form RichTextBox content (in realtime) with the output of the batch file execution without waiting for the batch command execution to finish
[英]batch file execution in c#
我正在從C#運行Java批處理文件。 如果我通過雙擊它運行它成功執行,但如果我從C#代碼運行它,它在線程中給出異常
“主”線程java.lang.noclassdeffoundError“中的異常”..
可能是什么原因以及如何解決? 我正在使用代碼:
var si = new ProcessStartInfo();
si.CreateNoWindow = true;
si.FileName = "batch-file path";
si.UseShellExecute = true;
Process.Start(si);
您很可能遺漏了系統環境變量中包含的一些參數。
嘗試像這樣設置工作目錄
process.StartInfo.WorkingDirectory = "C:\";
另外,嘗試這里提到的其他幾個選項,
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/20992653-dabf-4b31-85f7-e7bfbfb4557c
嘗試將以下代碼添加為批處理文件的第一行。
@cd /d %~dp0
不要使用batch_process_path +“\\”+而是使用Path.Combine()來確保路徑正確配有斜杠。
另請閱讀 “當UseShellExecute為true時,WorkingDirectory屬性指定可執行文件的位置”
所以把它設置為假。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.