Process::Start problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    Process::Start problem

    Hi o/

    I decided this morning to teach myself C++ \o/... 6 hours later Im just about ready to throw in the towel :)

    Anyways I have a minor annoyance you good ppl might be able to help me with.

    I created a simple code to open a .exe file in C# wich work fine (all hail C# :P)

    Code:
    System.Diagnostics.Process proc;
    proc = System.Diagnostics.Process.Start(@"C:\dotnetfx.exe");
    proc.WaitForExit();
    
    MessageBox.Show("omg");
    Now this is fairly simple. Runs the dotnet.exe and when that closes, it echo's "omg"

    And now for the problem.
    I tried to do the same thing in C++

    Code:
    System::Diagnostics::Process proc;
    proc.Start("C:\\dotnetfx.exe");
    proc.WaitForExit();
    
    MessageBox::Show("omgOMG");
    No matter what I do, the proc.. after I call the Start(...) function, gives me a Exception saying there is no proccess attached to it.

    I tried
    Code:
    proc = System::Diagnostics::Process::Start("C:\\dotnetfx.exe")
    but it gives me a build error.

    Anybody know what to do?
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    Are you running this in windows? If so, you can use

    Code:
    system("C:\\dotnetfx.exe");
    cout << "omg";
    return 0;
    to accomplish the same.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      I tried your code. It gives me a error:

      error C3861: 'system': identifier not found

      This is a part of a Windows application
      (Windows::Forms ::Form) thingie

      The code I posted is inside of a event triggered function, triggered when the form is displayed (this.Shown)

      The basic Idea is that I want this program to open up, install .Net framework and then execute my acctuall program, wich is wirtten in C#

      this is the entire code..

      Code:
      public ref class Form1 : public System::Windows::Forms::Form
      {
        public:
          Form1(void)
          {
            InitializeComponent();
      
            SetupStart::Form1::Shown::add(gcnew EventHandler(this, &SetupStart::Form1::Execute));
          }
      
        void Execute(Object^ sender, EventArgs^ eArgs)
        {
          // Here Im trying to install .Net
          System::Diagnostics::Proccess proc1;
          proc1.Start("C:\\dotnetfx.exe");
          proc1.WaitForExit();
        
          // This is where my C# app should start
          System::Diagnostics::Proccess proc2;
          proc2.Start("C:\\myapp.exe");
          Application::Exit();
        }
      }
      I'm using C++ Express 2005 to create this.

      Comment

      Working...