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. C / C++ / MFC
  4. how to rerun a process when it was terminated?

how to rerun a process when it was terminated?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++helpquestion
10 Posts 6 Posters 1 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.
  • I Offline
    I Offline
    iceman8616
    wrote on last edited by
    #1

    hi everybody! i have a problem by follow! for example, a.exe was running , now i terminate it by use the windows taskmanager, how to rerun a.exe when it was terminate by c/c++ code.

    A S C M 4 Replies Last reply
    0
    • I iceman8616

      hi everybody! i have a problem by follow! for example, a.exe was running , now i terminate it by use the windows taskmanager, how to rerun a.exe when it was terminate by c/c++ code.

      A Offline
      A Offline
      Adam Roderick J
      wrote on last edited by
      #2

      just refer [^]

      Величие не Бога может быть недооценена.

      1 Reply Last reply
      0
      • I iceman8616

        hi everybody! i have a problem by follow! for example, a.exe was running , now i terminate it by use the windows taskmanager, how to rerun a.exe when it was terminate by c/c++ code.

        S Offline
        S Offline
        Selvam R
        wrote on last edited by
        #3

        check with TerminateProcess Function http://msdn.microsoft.com/en-us/library/ms686714%28VS.85%29.aspx[^] How To Terminate an Application "Cleanly" in Win32 http://support.microsoft.com/kb/178893[^]

        Thanks and Regards, Selvam, http://www.wincpp.com

        1 Reply Last reply
        0
        • I iceman8616

          hi everybody! i have a problem by follow! for example, a.exe was running , now i terminate it by use the windows taskmanager, how to rerun a.exe when it was terminate by c/c++ code.

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          Probably you need another process monitoring the original one. The monitoring process may, for instance, poll every, say 10 seconds, for the original process status and launch it again when needed. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          D I 2 Replies Last reply
          0
          • I iceman8616

            hi everybody! i have a problem by follow! for example, a.exe was running , now i terminate it by use the windows taskmanager, how to rerun a.exe when it was terminate by c/c++ code.

            M Offline
            M Offline
            Michael Schubert
            wrote on last edited by
            #5

            Could you elaborate a bit further? You want to restart a program that was deliberately terminated via Task Manager by a user?

            I 1 Reply Last reply
            0
            • C CPallini

              Probably you need another process monitoring the original one. The monitoring process may, for instance, poll every, say 10 seconds, for the original process status and launch it again when needed. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              I once battled a "virus" that employed such a scheme. It polled every second, however. Delete A and B would start it back up. Delete B and A would start it back up.

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              C 1 Reply Last reply
              0
              • D David Crow

                I once battled a "virus" that employed such a scheme. It polled every second, however. Delete A and B would start it back up. Delete B and A would start it back up.

                "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                Well, I suppose it maybe a schema for some viruses. It is also a rather obvious mechanism (at least I hope...). :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                1 Reply Last reply
                0
                • M Michael Schubert

                  Could you elaborate a bit further? You want to restart a program that was deliberately terminated via Task Manager by a user?

                  I Offline
                  I Offline
                  iceman8616
                  wrote on last edited by
                  #8

                  yes,and must use c/c++ code to restart.

                  1 Reply Last reply
                  0
                  • C CPallini

                    Probably you need another process monitoring the original one. The monitoring process may, for instance, poll every, say 10 seconds, for the original process status and launch it again when needed. :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    I Offline
                    I Offline
                    iceman8616
                    wrote on last edited by
                    #9

                    how to check the original process is live by the process's name?

                    C 1 Reply Last reply
                    0
                    • I iceman8616

                      how to check the original process is live by the process's name?

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #10

                      Finding a process by name is a rather lenghty operation (you must go through EnumWindows [^]). Perhaps a better option would be storing the process handle (if application A starts application B via CreateProcess [^] then A may store the B process handle) and call GetExitCodeProcess [^] when needed. :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                      [My articles]

                      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