How to run a exe on C Sharp?

December 1, 2010 at 15:09:31
Specs: Windows 7, 3 GB
Code works perfect with IE but not the program I'm trying to run. Code used:

System.Diagnostics.Process Proc = new System.Diagnostics.Process();
Proc.StartInfo.FileName = "Mabinogi.exe";
Proc.Start();

Please help.


See More: How to run a exe on C Sharp?

Report •

#1
December 1, 2010 at 19:49:26
Okay. And? What exception is thrown, if any? What's the return value?

How To Ask Questions The Smart Way


Report •

#2
December 2, 2010 at 14:18:02
I'm new to C#, so take it easy with the vocabulary.

Report •

#3
December 2, 2010 at 15:40:01
http://en.wikipedia.org/wiki/Except...
Wordy article, but for you it boils down to, "If you don't catch these, they'll crash your program (or get VS to complain)."

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
December 2, 2010 at 17:34:14
Don't think that's the problem the error I encounter is that it cannot be found.

Report •

#5
December 3, 2010 at 05:54:23
There you go; your exception is File Not Found. Windows cannot find your "Mabinogi.exe". That means it's not in (as copied from MSDN's CreateProcess() function):
1. The directory from which the application loaded.
2. The current directory for the parent process.
3. The 32-bit Windows system directory.
4. The 16-bit Windows system directory.
5. The Windows directory.
6. The directories that are listed in the PATH environment variable.
-- Probably the [HKCU | HKLM]\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\ registry key.

I'd suggest you provide the full path to "Mabinogi.exe", and not just the name.

How To Ask Questions The Smart Way


Report •

#6
December 3, 2010 at 18:58:26
It is clear that you haven't specified the path. If the file is in the C:\blah\bin directory, for example, write it this way:
Proc.StartInfo.FileName = "C:\\blah\\bin\\Mabinogi.exe";
but note the double backslashes \\ this is because the backslash needs to be escaped out or else c# thinks you're trying to use a special character there.

Report •

#7
December 4, 2010 at 10:39:39
Thanks so much Nuklear! So that's why my pathing didn't work before I didn't know it require double backslashes, thanks very much!

Report •

#8
April 6, 2011 at 07:37:08
thanx a lot nuclear.. was having the same problem :) thank you

Report •

Ask Question