2014-07-14 88 views
0

我试图通过C#代码将.exe传递给另一个。使用另一个可执行文件的命令行参数启动进程

这里是我到目前为止的代码:

string ex1 = System.Windows.Forms.Application.StartupPath.ToString() + "\\dev\\psm.exe"; 
string ex2 = System.Windows.Forms.Application.StartupPath.ToString() + "\\dev\\Application\\app.exe"; 

ProcessStartInfo startInfo = new ProcessStartInfo(); 
startInfo.CreateNoWindow = false; 
startInfo.UseShellExecute = false; 
startInfo.FileName = ex1; 
startInfo.WindowStyle = ProcessWindowStyle.Normal; 
startInfo.Arguments = ex2; 

try 
{ 
    Process.Start(startInfo); 
} 
catch 
{ 
} 

哪个参数就可以用作一个文件拖到应用程序?
详细信息:
当您正常运行psm.exe时,它会提示输入文件名和目录。
Running psm.exe


然而,当你拖上psm.exe批准的应用程序, Running file with psm.exe
它自动加载应用程序。 Running app



这怎么用C#来完成?

回答

0

可以同步运行其他应用程序是这样的:

System.Diagnostics.Process myapp = new System.Diagnostics.Process(); 
myapp.StartInfo.FileName = ex1; 
myapp.StartInfo.Arguments = ex2; 
myapp.Start(); 
myapp.WaitForExit(); 

根据您要启动的应用程序是如何预期的命令行参数来传递,你可能需要这个参数:

myapp.StartInfo.Arguments = String.Format("/MyArgumentName={0}", ex2); 

这将是等效的:

c:\MyApplicationStartupPath\dev\psm.exe /MyArgumentName=c:\MyApplicationStartupPath\Application\App.exe 

务必确认日e方式app.exe需要StartInfo.Arguments中的参数

+0

这将启动psm.exe并将参数传递给app.exe – Geoff

+0

没有工作。只打开第一个.exe然后终止。 – GTAWWEKID

+0

我更新了我的问题,了解更多详情。 – GTAWWEKID

相关问题