0
我有一個小問題。好吧,讓我們從我的C#控制檯應用程序說我想運行一個批處理文件,將採取一個參數。我的C#應用程序停止處的字符串變量將是傳遞給批處理文件的字符串參數。我該怎麼去做呢?從C#執行批處理文件#
這是到目前爲止我的代碼我的C#控制檯程序:
//String argument to pass to the batch file
string message = "Hello World";
System.Diagnostics.Process process = new System.Diagnostics.Process();
//startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "Greetings.bat";
startInfo.Arguments = "/C " + message;
process.StartInfo = startInfo;
process.Start();
我的批處理文件
CLS
@ECHO OFF
ECHO %1
可能重複(http://stackoverflow.com/questions/361097/c-sharp-service-cannot-execute-batch-file) – Bernard 2012-08-11 13:49:01
或http:/ /stackoverflow.com/questions/7101326/running-a-batch-file-from-c-sharp – 2012-08-11 13:56:01