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#
  4. How to kill a process in C#

How to kill a process in C#

Scheduled Pinned Locked Moved C#
csharphelptutorial
12 Posts 6 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.
  • P phantanagu

    Hello Help me to kill a process in C# Thanks in advance.

    K Offline
    K Offline
    Keshav V Kamat 0
    wrote on last edited by
    #3

    check this recent article in codeproject.com http://www.codeproject.com/Purgatory/ProcessKiller.asp it describes everything

    Keshav Kamat :) India

    R 1 Reply Last reply
    0
    • K Keshav V Kamat 0

      check this recent article in codeproject.com http://www.codeproject.com/Purgatory/ProcessKiller.asp it describes everything

      Keshav Kamat :) India

      R Offline
      R Offline
      Ram Krishna Wagle
      wrote on last edited by
      #4

      //This is just a simple way to accomplish the task System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcesses(); for(int cPr=0; cPr Waamax. -- Your life is what your thoughts make it.

      M P 2 Replies Last reply
      0
      • R Ram Krishna Wagle

        //This is just a simple way to accomplish the task System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcesses(); for(int cPr=0; cPr Waamax. -- Your life is what your thoughts make it.

        M Offline
        M Offline
        Martin 0
        wrote on last edited by
        #5

        Hello, Never forget to "Dispose()" the process instances!!!! All the best, Martin

        1 Reply Last reply
        0
        • R Ram Krishna Wagle

          //This is just a simple way to accomplish the task System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcesses(); for(int cPr=0; cPr Waamax. -- Your life is what your thoughts make it.

          P Offline
          P Offline
          phantanagu
          wrote on last edited by
          #6

          I need kill a process whose image name is "QLSX.vghost.exe". How should I do ? System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcesses(); for(int cPr=0; cPr { //kill the available processes prCess[cPr].Kill(); } this code above shows how to kill all processes. I 'm not sure I need to kill all. Help me how to kill a identified process ?

          T K 2 Replies Last reply
          0
          • P phantanagu

            I need kill a process whose image name is "QLSX.vghost.exe". How should I do ? System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcesses(); for(int cPr=0; cPr { //kill the available processes prCess[cPr].Kill(); } this code above shows how to kill all processes. I 'm not sure I need to kill all. Help me how to kill a identified process ?

            T Offline
            T Offline
            theScorp
            wrote on last edited by
            #7

            System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcessesByName("QLSX.vghost.exe"); prCess[0].Kill(); Simple :)

            "If our Mind can, the Program can !!"

            K M 2 Replies Last reply
            0
            • P phantanagu

              I need kill a process whose image name is "QLSX.vghost.exe". How should I do ? System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcesses(); for(int cPr=0; cPr { //kill the available processes prCess[cPr].Kill(); } this code above shows how to kill all processes. I 'm not sure I need to kill all. Help me how to kill a identified process ?

              K Offline
              K Offline
              Keshav V Kamat 0
              wrote on last edited by
              #8

              try this instead System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("QLSX.vghost.exe"); for(int i=0 ; i

              1 Reply Last reply
              0
              • T theScorp

                System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcessesByName("QLSX.vghost.exe"); prCess[0].Kill(); Simple :)

                "If our Mind can, the Program can !!"

                K Offline
                K Offline
                Keshav V Kamat 0
                wrote on last edited by
                #9

                u can kill a single process by that name. sometimes however there are threads of the same process running parallely. so killing just a single process would not help. It is therefore preferable to have all the processes by a similar name killed together, so that there are no problems. if there is just a single process, then it will kill it anyways. So in my opinion, please use the code where a collection of the processes is returned by name and you kill them all using a for loop. i hope its clear.

                Keshav Kamat :) India

                1 Reply Last reply
                0
                • T theScorp

                  System.Diagnostics.Process[] prCess =System.Diagnostics.Process.GetProcessesByName("QLSX.vghost.exe"); prCess[0].Kill(); Simple :)

                  "If our Mind can, the Program can !!"

                  M Offline
                  M Offline
                  Martin 0
                  wrote on last edited by
                  #10

                  Hello, + If there is no instance of the process running you will get an exception. So always check he lenght of the array! All the best, Martin

                  P K 2 Replies Last reply
                  0
                  • M Martin 0

                    Hello, + If there is no instance of the process running you will get an exception. So always check he lenght of the array! All the best, Martin

                    P Offline
                    P Offline
                    phantanagu
                    wrote on last edited by
                    #11

                    It's working well. Thanks for all you. I appreciate you so much. Tan.

                    1 Reply Last reply
                    0
                    • M Martin 0

                      Hello, + If there is no instance of the process running you will get an exception. So always check he lenght of the array! All the best, Martin

                      K Offline
                      K Offline
                      Keshav V Kamat 0
                      wrote on last edited by
                      #12

                      ya. in that case. use a try catch (finally) block. U need not be concerned if the process is not present and thus can ignore.

                      Keshav Kamat :) India

                      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