vb: how to kill running process / application / program?
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:
If you do not want to kill the program, but just hide the program from the tasklist, you can use the code as follows:
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
Set oServices = Nothing
Set oWMI = Nothing
app.TaskVisible = false