Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Executing external application(.exe file) from windows application in C#.net

Executing external application(.exe file) from windows application in C#.net

Scheduled Pinned Locked Moved Windows Forms
csharpannouncementalgorithmshelp
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vishnu Nath
    wrote on last edited by
    #1

    Hii, After searching on for auto update feature to suit my needs/project, i started developing my own auto update feature. This application basically compares the version of my file and any difference in it, it will download the newest version of that file. Now problem is , i want to fire or start an .exe application/my main application whenever i find that there is no version update . And close auto update application before starting my different application . I tried out using system.process.Diagnostic.Process method But didnt succeeded. Can anyone show me how i can open different application from my current application and close the current application before starting different application. :(

    Aspiring Techie, Vishnu Nath

    L 1 Reply Last reply
    0
    • V Vishnu Nath

      Hii, After searching on for auto update feature to suit my needs/project, i started developing my own auto update feature. This application basically compares the version of my file and any difference in it, it will download the newest version of that file. Now problem is , i want to fire or start an .exe application/my main application whenever i find that there is no version update . And close auto update application before starting my different application . I tried out using system.process.Diagnostic.Process method But didnt succeeded. Can anyone show me how i can open different application from my current application and close the current application before starting different application. :(

      Aspiring Techie, Vishnu Nath

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Proces.Start is the easiest way to start a program.

      Vishnu Nath wrote:

      But didnt succeeded.

      Did you get an error? If so, what was the message? Can you post the code you used?

      I are troll :)

      V 1 Reply Last reply
      0
      • L Lost User

        Proces.Start is the easiest way to start a program.

        Vishnu Nath wrote:

        But didnt succeeded.

        Did you get an error? If so, what was the message? Can you post the code you used?

        I are troll :)

        V Offline
        V Offline
        Vishnu Nath
        wrote on last edited by
        #3

        Now i have changed the way i used the code. Now i use my process.start code in Program.cs file. But it is behaving in a different manner.

        static void Main()
        {
        string appPath = applicationPath();
        try
        {

                    if (checkInternetConnection() == true)
                    {
                        if (setXML() == true)
                        {
                            Application.EnableVisualStyles();
                            Application.SetCompatibleTextRenderingDefault(false);
                            Application.Run(new Update());
                        }
                        else
                        {
                            Process.Start(appPath);
                        }
                    }
                    else
                    {
                        Process.Start(appPath);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    Process.Start(appPath);
        
                }
        

        appPath is the path of main application retrieved from applicationPath() method. and setXml() is a method returning boolean value. Now if update is available. the application will fire Update Form else it will start my main app. But instead the application runs , but its control and text are not visible. When Update Form runs, Form is blank without any controls in it. I m unable to understand what happens that my controls and heading form becomes invisible during runtime. Can u sort out the problem?

        Aspiring Techie, Vishnu Nath

        L 1 Reply Last reply
        0
        • V Vishnu Nath

          Now i have changed the way i used the code. Now i use my process.start code in Program.cs file. But it is behaving in a different manner.

          static void Main()
          {
          string appPath = applicationPath();
          try
          {

                      if (checkInternetConnection() == true)
                      {
                          if (setXML() == true)
                          {
                              Application.EnableVisualStyles();
                              Application.SetCompatibleTextRenderingDefault(false);
                              Application.Run(new Update());
                          }
                          else
                          {
                              Process.Start(appPath);
                          }
                      }
                      else
                      {
                          Process.Start(appPath);
                      }
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show(ex.Message);
                      Process.Start(appPath);
          
                  }
          

          appPath is the path of main application retrieved from applicationPath() method. and setXml() is a method returning boolean value. Now if update is available. the application will fire Update Form else it will start my main app. But instead the application runs , but its control and text are not visible. When Update Form runs, Form is blank without any controls in it. I m unable to understand what happens that my controls and heading form becomes invisible during runtime. Can u sort out the problem?

          Aspiring Techie, Vishnu Nath

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I can't see any reason here why the Update-form would hide it's controls, unless there's some kind of weird exception. I wouldn't change the Program.cs, instead, I would have put the Process.Start code somewhere in the Update-form. Perhaps that any of the other members see a potential source of the error?

          I are troll :)

          V 2 Replies Last reply
          0
          • L Lost User

            I can't see any reason here why the Update-form would hide it's controls, unless there's some kind of weird exception. I wouldn't change the Program.cs, instead, I would have put the Process.Start code somewhere in the Update-form. Perhaps that any of the other members see a potential source of the error?

            I are troll :)

            V Offline
            V Offline
            Vishnu Nath
            wrote on last edited by
            #5

            Since i want either of the form to open. i.e either Update form if update is available or else my main app if there is no update. Hence i chose it to include process.start code in program.cs file. :doh:

            Aspiring Techie, Vishnu Nath

            L 1 Reply Last reply
            0
            • V Vishnu Nath

              Since i want either of the form to open. i.e either Update form if update is available or else my main app if there is no update. Hence i chose it to include process.start code in program.cs file. :doh:

              Aspiring Techie, Vishnu Nath

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Vishnu Nath wrote:

              Since i want either of the form to open.

              The check might take a while, depending on connectivity. I'd still recommend showing a form with a message "Hold on, checking for new cool stuff!". Alternatively, this worked for me; Program.cs

                  /// /// The main entry point for the application.
                  /// 
                  \[STAThread\]
                  static void Main()
                  {
                      Application.EnableVisualStyles();
                      Application.SetCompatibleTextRenderingDefault(false);
              
                      if (true) <- perform update check here :)
                      {
                          System.Diagnostics.Process.Start("Calc.exe");
                      }
                      else
                      {
                          Application.Run(new Form1());
                      }
                  }
              

              I are troll :)

              1 Reply Last reply
              0
              • L Lost User

                I can't see any reason here why the Update-form would hide it's controls, unless there's some kind of weird exception. I wouldn't change the Program.cs, instead, I would have put the Process.Start code somewhere in the Update-form. Perhaps that any of the other members see a potential source of the error?

                I are troll :)

                V Offline
                V Offline
                Vishnu Nath
                wrote on last edited by
                #7

                Eddy Vluggen wrote:

                Update-form would hide it's controls

                i got my mistake, i got the reason why Update form hided its control. Its because by mistake i commented out the InitializeComponent() method in Update's constructor, that led to hiding of the controls in the form. :-O

                Aspiring Techie, Vishnu Nath

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups