tags:

views:

76

answers:

2

I'm trying launch an application using c#, and have been experimentiing with the following line, if I run this from a cmd prompt it's ok but when running in my forms app it fails.

Process.Start(@"C:\Program Files (x86)\Activision\Call of Duty 4 - Modern Warfare\iw3mp.exe","+connect 91.192.210.47:2304");

The Error is Win_Improper_quit_body

any ideas.

A: 

You should put the arguments part in Arguments property of ProcessStartInfo

Here's an example:

ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Minimized;

            Process.Start(startInfo);

            startInfo.Arguments = "www.northwindtraders.com";

            Process.Start(startInfo);
Beatles1692
I think the OP is already using an overload of Process.Start that accepts an arguments param, I don't think using ProcessStartInfo would be any different?
Matthew Brindley
+1  A: 

I believe the particular executable you're trying to launch expects the working directory to be set correctly.

var processStartInfo = new ProcessStartInfo(pathToExe, args);
processStartInfo.WorkingDirectory = Path.GetDirectoryName(pathToExe);
Process.Start(processStartInfo);

See here for more info.

Matthew Brindley
I'll try this when I get back, cheers.
RubbleFord