C# expression for launching an exe file

Davina1961

Newbie
Joined
May 17, 2006
Messages
144
Reaction score
0
Hi, I know these forums are pretty dead but I dont want to join another. I'm building a program in c# which I'm pretty new to. I want to launch a different program via a button in this program, specificly msn messenger. As most people have msn instaleld in the same directory I just want to simply link to "c:\program_files\MSN_Messenger\msnmsgr.exe"

So basicly what expression can I use to launch this file with the given link. or is there a better way to find the executable file?

Thanks in advance if anyone can help.
 
Ah sorry it's:

Process.Start();

with using System.Diagnostics; at the top of the file.
 
If you link to "c:\program_files\MSN_Messenger\msnmsgr.exe", you'll be stuck because those folder names have spaces, not underscores ;).

Anyhow, it's a fairly bad thing to do. At the very least, be sure you check to see if the file exists first - if it doesn't, and you don't check, your program will have an execution error. Of course, by far the best thing to do is to check where MSN Messenger is installed through the registry. I think the key is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MessengerService but I may not remember correctly.
 
You should also give the user an option to select the file if it's elsewhere. This will help out people who modify a lot of stuff in windows.
 
you can include spaces in the link. Yeah thats a good idea about checking where it is and also giving the option to select it.
 
Back
Top