【发布时间】:2014-04-21 14:00:39
【问题描述】:
我有一个程序需要从 cmd 运行并带有参数,比如调用的执行文件
程序.exe
我需要从 cmd 中使用 args 运行它,cmd 中的整个命令如下所示:
c:\ram\program.exe /path = c:\program files\NV
如您所见,路径是:“c:\ram\”
执行文件为:“program.exe”
我需要发送的参数是:/path = c:\program files\NV
我该怎么做?
我尝试像这样打开进程:
string strArguments = @"/path = c:\program files\NV";
Process p = new Process();
p.StartInfo.FileName = "program.exe";
p.StartInfo.WorkingDirectory = "c:\\ram\\";
p.StartInfo.Arguments = strArguments;
p.Start();
它不好,我认为问题可能是我没有从 CMD 访问 exe 文件,也许我错了......任何人都知道我该怎么做?
谢谢
【问题讨论】:
-
代码行 p.StartInfo.WorkingDirectory = "c:\ram\";不起作用。应该是 p.StartInfo.WorkingDirectory = @"c:\ram\";
-
我想念在我的程序中的消息中写了它:p.StartInfo.WorkingDirectory = "c:\\ram\\"
标签: c# process cmd command-line-arguments