running .exe file from my program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RedRose2009
    New Member
    • Oct 2009
    • 5

    running .exe file from my program

    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.
  • Saser
    New Member
    • Jul 2009
    • 17

    #2
    Try this:

    Code:
    using System.Diagnostics;
    
    ...
    
    Process someProcess = new Process();
    someProcess.StartInfo.FileName = @"<complete path to executable file here>";
    someProcess.StartInfo.Arguments = ""; // If you want to pass some arguments to the file being executed
    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.

    Comment

    • fastestindian
      New Member
      • Aug 2009
      • 74

      #3
      Code:
      System.Diagnostics.ProcessStartInfo info = new ProcessStartInfo(filePath,fileName );
            Process pdfCreationProcess = new Process();
            pdfCreationProcess.StartInfo = info;
            pdfCreationProcess.Start();
            pdfCreationProcess.WaitForExit();
            pdfCreationProcess.Exited += new EventHandler(fileCreationProcess_Exited);
            pdfCreationProcess.EnableRaisingEvents = true;
            pdfCreationProcess.Close();
      Use fileCreationPro cess_Exited event to run the code which needed to be run after exiting the targeted exe

      Comment

      Working...