Connecting Tech Pros Worldwide Help | Site Map

running .exe file from my program

Newbie
 
Join Date: Oct 2009
Posts: 4
#1: 3 Weeks Ago
Hello,

I am working on a C#.NET project that needs to call .exe file from a project that I previously worked on. So, basically project A, needs to call project B. I am not sure how to do it. I tried calling with Process.Start ("something.exe"), but nothing happens so I am thinking maybe I have to be more specific to where exactly something.exe is located. Does something.exe has to be inside the same folder as project A? When I look for something.exe of my project B, I have two folders obj & bin, inside which of these is the .exe file that program A needs to run? I hope this is not too confusing....

This is really urgent and any help would be highly appreciated!

Thanks!

P.S. When project A tries to run exe file of my project B using Process.Start I get the error saying the project encountered a problem and needs to close down. I think the issue is with the location of my exe file.
Newbie
 
Join Date: Jul 2009
Posts: 17
#2: 3 Weeks Ago

re: running .exe file from my program


Try this:

Expand|Select|Wrap|Line Numbers
  1. using System.Diagnostics;
  2.  
  3. ...
  4.  
  5. Process someProcess = new Process();
  6. someProcess.StartInfo.FileName = @"<complete path to executable file here>";
  7. someProcess.StartInfo.Arguments = ""; // If you want to pass some arguments to the file being executed
  8. someProcess.Start();
Be sure to include the @ in FileName, because otherwise you'd need to use double backslashes in the path. Not really necessary, but it's for convenience.
Member
 
Join Date: Aug 2009
Posts: 33
#3: 3 Weeks Ago

re: running .exe file from my program


Expand|Select|Wrap|Line Numbers
  1. System.Diagnostics.ProcessStartInfo info = new ProcessStartInfo(filePath,fileName );
  2.       Process pdfCreationProcess = new Process();
  3.       pdfCreationProcess.StartInfo = info;
  4.       pdfCreationProcess.Start();
  5.       pdfCreationProcess.WaitForExit();
  6.       pdfCreationProcess.Exited += new EventHandler(fileCreationProcess_Exited);
  7.       pdfCreationProcess.EnableRaisingEvents = true;
  8.       pdfCreationProcess.Close();
Use fileCreationProcess_Exited event to run the code which needed to be run after exiting the targeted exe
Reply

Tags
.exe