vb: how to kill running process / application / program?
Website Design
Website Promotion
Graphic Design
Programming
Free Software
Computer Tips
Discount Stores
|
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
|