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