Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Kill  (Read 2928 times)

0 Members and 1 Guest are viewing this topic.

dj-allen

    Topic Starter


    Rookie
  • Thanked: 1
  • Experience: Experienced
  • OS: Windows 7
Kill
« on: December 02, 2010, 11:56:33 AM »
I need to make an .exe to kill a task. I am useing Microsoft Visual Studio. I have more then one task that i need it to kill. But i am going to have a file for each task. I dont know how to do it. Can you help me out. That would be the best.

dj-allen

    Topic Starter


    Rookie
  • Thanked: 1
  • Experience: Experienced
  • OS: Windows 7
Re: Kill
« Reply #1 on: December 02, 2010, 12:14:35 PM »
Code: [Select]
Module Module1

    Sub Main()
        Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("TeamViewer")

        For Each p As Process In pProcess
            p.Kill()
        Next

    End Sub

End Module

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Kill
« Reply #2 on: December 02, 2010, 12:47:08 PM »
We think your are a new programmer.
Even veteran programmers can get this wrong.

Some questions.
Are these processes are things you have written?
If not, do yoou know if the programs involved have a provision for early termination?
And why are you wanting to kill them by name?
Did you start the processes involved?
The is a considerable security issue trying to kill a bunch of processes that you do not fully control. And you could crash the whole system.
You can get more information from the online Help and Knowledge base. Or somebody here will walk you through it.

But meanwhile, I will try to blame some of the issues involved in killing a process where you don't know a lot of intimate information about that process.
It is true that you can identify a process by its name. But there is some big pitfalls with that. Here's just one, there many programs that are called 'setup' and two or more of them could be running at the same time and have not come to their natural termination and you might want to terminate them prematurely. So which one would you terminate? Are you sure?
I'm not trying to be funny nor be very critical of your skills. But being able to write code is one thing, but to understand what you're doing and the impact it may have on the entire system may be another matter. Windows does allow two or more programs to have the same name and be running at the same time. They could've started from different directories. Then there's the matter of instance. Some programs when invoked a second time will start a new instance of the same program. This is allowed, even though it may not seem like a good idea.
So then, what would be the best way to kill a number of processes? First, you need to get an ID of the process that you want to kill. The name is not enough, unless you're very very sure that there is only one program with that name and that it never would have more than one instance. Otherwise you should already know what is the ID that Windows has given to you. If you started the process.
At this point I'm not able to give you more information, but I just wanted to question you about what you're up against.
 :D

dj-allen

    Topic Starter


    Rookie
  • Thanked: 1
  • Experience: Experienced
  • OS: Windows 7
Re: Kill
« Reply #3 on: December 02, 2010, 02:57:22 PM »
I have this program on my flash drive. And they stopped making the software for it. So I found a way to add in my own software to it. But I needed to have it end the Process of the program so i can eject the flash drive.