chitika

Sunday, September 11, 2011

How to kill / terminate a running process / program in vb?

This site provides users with the information about vb, visual basic, vb6, kill running process, terminate running application, end running program, hide program from tasklist, how to kill running process, how to terminate running application, how to end running program, how to hide program from tasklist, and more.

If you think that this site is helpful, please recommend your friends to visit our site.

How to kill / terminate a running process / program?

The following is the code to kill / terminate a running process / application that is listed in tasklist:


--------------------------------------------------------------------------------
Dim oWMI
Dim ret
Dim sService
Dim oWMIServices
Dim oWMIService
Dim oServices
Dim oService
Dim servicename
Dim appname

appname = "test.exe" 'app to be terminated

Set oWMI = GetObject("winmgmts:")
Set oServices = oWMI.InstancesOf("win32_process")

For Each oService In oServices
servicename = LCase(Trim(CStr(oService.Name) & ""))
If InStr(1, servicename, LCase(appname), vbTextCompare) > 0 Then
ret = oService.Terminate
End If
Next

Set oServices = Nothing
Set oWMI = Nothing
--------------------------------------------------------------------------------

If you do not want to kill the program, but just hide the program from the tasklist, you can use the code as follows:
app.TaskVisible = false

No comments:

Post a Comment

For other hundreds of computer repair tips, tricks, tweaks, guide, help, please go to


http://website.edusoftmax.com