Launching Process

Hi,

I would like to launch a process from within my application, at present I am using the System.Diagnostics.Process class to launch the process. In addition, I am passing in any command line arguments using the second parameter of the start method, e.g. :

   System.Diagnostics.Process.Start(oTask.Command, oTask.Arguments);

This works fine for most things. However it doesnt seem to work when the target is specified in the same format as the target field within a Windows Shortcut, for example if the target path of the shortcut is:

Comms.exe WaitForExit=0

I pass this as:

      System.Diagnostics.Process.Start("Comms.exe","WaitForExit=0");

Any ideas?

Thanks

LVL 1
paulsidebottomAsked:
Who is Participating?
 
Fahad MukhtarConnect With a Mentor Distinguished EngineerCommented:
         System.Diagnostics.Process p = new System.Diagnostics.Process();
                System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
                si.FileName = "notepad.exe";
                p.StartInfo = si;
                p.Start();
                p.WaitForExit();

you can use the si.arguments to pass arguments
0
 
seaziumCommented:
chk it out .., it will describe u better
http://www.codeproject.com/csharp/HowToLaunchProcess.asp

dZ..,
0
 
seaziumCommented:
another 1 .., little bit more brief

http://www.codeproject.com/csharp/LaunchProcess.asp

dZ..,
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
paulsidebottomAuthor Commented:
Thanks for the replies but as stated, I am already using the arguments property to pass command arguments.  It seems the problem may not originate from the use the of command arguments more the process equivalent of Windows "start in" property.

Does anyone know how the start in property can be specified for a process?

Thanks.
0
 
paulsidebottomAuthor Commented:
Apologies, I forgot I posted this - yes I'm happy with the resolution. Thanks for your answers.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.