locked
How to kill a process using C# RRS feed

  • Question

  • So, im working on something and I need a way to kill Roblox, using a button. Anyone help me out?
    Thursday, March 7, 2019 4:28 AM

All replies

  • So, im working on something and I need a way to kill Roblox, using a button. Anyone help me out?

    You can use 

               Process.GetProcessByName()  // see the doc

    and then identify your specific process, and then call

               Process.CloseMainWindow() // see the doc
               Process.Close()  // see the doc

    on the instance you obtained, to close smoothly.

    But, if you wanna really kill it, call, instead,

               Process.Kill()  // see the doc


    Thursday, March 7, 2019 5:23 AM
  • Thursday, March 7, 2019 5:24 AM
  • Hi MLG5006,

    Thank you for posting here.

    According to your description, you want to kill a process by using a button in c#.

    You could try the following code.

       private void button1_Click(object sender, EventArgs e)
            {
                foreach (var process in Process.GetProcessesByName("Notepad"))
                {
                    process.Kill();
                }
            }
    

    Result:

    Best regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 8, 2019 5:22 AM
    Moderator
  • So, im working on something and I need a way to kill Roblox, using a button. Anyone help me out?

    You can use 

               Process.GetProcessByName()  // see the doc

    and then identify your specific process, and then call

               Process.CloseMainWindow() // see the doc
               Process.Close()  // see the doc

    on the instance you obtained, to close smoothly.

    But, if you wanna really kill it, call, instead,

               Process.Kill()  // see the doc


    Unbelievable! Why didn't you just shut up? This is so wrong! Stop posting your rubbish# thinkings ritehere!

    FYI: It's called GetProcessesByName and it needs a string as parameter...

    Friday, March 8, 2019 9:35 AM
  • What i didint understand is why ppl like "ritehere44" posting answers like this... #bullshit

    FYI: Like others said you need to add parameter as string in the call of the method.

    Best regards,

    AlbanaInDerCopacabana

    Friday, March 8, 2019 9:54 AM

  • Unbelievable! Why didn't you just shut up? This is so wrong! Stop posting your rubbish# thinkings ritehere!

    FYI: It's called GetProcessesByName and it needs a string as parameter...

    There's nothing wrong, dude peeved sore and ignorant programmer.

    See that method's definition:

    The method returns an array, @stupiDerChris, and the OP must identify which he/she wants to "kill".

    Also, I wrote, clearly, many times, "see the doc" for the details.

    Notice too, I did not post any code, just guidance(!), @stupiDerChris aka rubbish# coder.

    P.S.

    When I say you are a rubbish# coder, I'm not wrong; you have proved once more that you're unable to reason correctly, even for simple things, like the one above.


    • Edited by ritehere44 Saturday, March 9, 2019 3:44 AM
    Saturday, March 9, 2019 3:43 AM
  • What i didint understand is why ppl like "ritehere44" posting answers like this... #bullshit

    FYI: Like others said you need to add parameter as string in the call of the method.

    Best regards,

    AlbanaInDerCopacabana

    ?

    Once more, @stupiDerChris, you come to a thread to ruin it!

    Now, not happy in just ruining it, you brought your husband with you.

    Your avatar never fooled me, @stupiDerChris (or should I say @stupiDerChristine?).

    Saturday, March 9, 2019 3:49 AM