Results 1 to 12 of 12

Thread: stopping a background process from task manager

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Resolved stopping a background process from task manager

    Hey there everyone,

    I got a little problem!
    I wanted to execute a program which I deliver with my software package, but after running it I can't kill the task.

    I used this:
    Code:
    For Each p As Process In Process.GetProcessesByName("helper.exe")
                        p.Kill()
                       
                    Next
    That won't work because it's... I don't really know!
    I even tried to make it a process in a separate SUB but that won't work either.

    Can someone please help me out here?

    With kind regards,
    Dennis
    Last edited by teambiohazard; Aug 12th, 2015 at 05:09 AM.

  2. #2
    Member
    Join Date
    Sep 2013
    Posts
    59

    Re: stopping a background process from task manager

    this may help?

    Process[] procs = Process.GetProcessesByName("helper");

    foreach (Process proc in procs)
    proc.Kill();

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Re: stopping a background process from task manager

    nope, I got a bunch of errors. tried to modify the code you gave but can't figure out what will solve it.

    I am using visual studio 2010 windows form application.

  4. #4
    Member
    Join Date
    Sep 2013
    Posts
    59

    Re: stopping a background process from task manager

    OK can you remove the .exe from you're sample code or heres the converted to VB code

    Code:
    Dim procs As Process() = Process.GetProcessesByName("helper")
    
    For Each proc As Process In procs
    	proc.Kill()
    Next

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Re: stopping a background process from task manager

    still not working. it seems that the file doesn't get terminated.

  6. #6
    Member
    Join Date
    Sep 2013
    Posts
    59

    Re: stopping a background process from task manager

    are you running VS with admin rights? You may need Admin.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: stopping a background process from task manager

    Ok... help me out here... WHAT application are you trying to terminate? Yours? Or something else? Is the process trying to kill itself? O.o

    -tg
    Last edited by techgnome; Aug 11th, 2015 at 06:31 AM.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Re: stopping a background process from task manager

    Quote Originally Posted by techgnome View Post
    Ok... help me out here... WHAT application are you trying to terminate? Yours? Or something else? Is the process trying to kill itself? O.o

    -tg
    I am trying to terminate my server application.

    and it isn't really the purpose to end itself

  9. #9
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: stopping a background process from task manager

    So at a guess do you have a client and a server application and you trying to kill the Server app from the Client?

    Is your server application running on the same machine?

    If you debug and step through fenster89411's code - does it even find your helper application?

    Code:
    Dim procs As Process() = Process.GetProcessesByName("helper")
    
    For Each proc As Process In procs
    	proc.Kill()
    Next
    If you put a breakpoint on proc.kill does it even get hit when you run the code?
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  10. #10

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    8

    Resolved Re: stopping a background process from task manager

    Quote Originally Posted by NeedSomeAnswers View Post
    So at a guess do you have a client and a server application and you trying to kill the Server app from the Client?

    Is your server application running on the same machine?

    If you debug and step through fenster89411's code - does it even find your helper application?

    Code:
    Dim procs As Process() = Process.GetProcessesByName("helper")
    
    For Each proc As Process In procs
    	proc.Kill()
    Next
    If you put a breakpoint on proc.kill does it even get hit when you run the code?
    Thanks!

  11. #11
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: stopping a background process from task manager

    Thanks for what exactly?

    i asked you a bunch of questions, did they help you understand what your problem was?

    and if you fixed your issue can you post back what was actually wrong and how you fixed it?
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  12. #12
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: stopping a background process from task manager

    And yet it was the exact same code previously posted that he said was "still not working" ...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width