Hola amigos, me preguntaba si me podriais ayudar en una duda que tengo de como
cerrar un proceso sabiendo el nombre del mismo...
Desde ya, gracias!!
Salu2
Ranslsad
jaja xD justo ayer estaba buscando eso.. y lo encontre... hay muchos ejemplos!
busca!!... pone cerrar procesos en el buscador y salen montones de formas... tb esta sabiendo el nombre y/o la ruta... hay formas con API's, con funciones... hay banda... busca un poco q salen un monton
Aqui te dejo la funcion que se encarga de finalizar un proceso.
Acostumbrate a buscar, este codigo anda por la red desde hace buen tiempo...
Consulta a google, la biblioteca de codigos, el buscador interno del foro...
Public Sub KillProcess(ByVal processName As String)
'---CAPTURA DE ERROR---
On Error GoTo ErrHandler
'----------------------
'---DECLARACIÓN DE VARIABLES---
Dim oWMI
Dim ret
Dim sService
Dim oWMIServices
Dim oWMIService
Dim oServices
Dim oService
Dim servicename
'------------------------------
'--------------------SE OBTIENEN OBJETOS--------------------
Set oWMI = GetObject("winmgmts:")
Set oServices = oWMI.InstancesOf("win32_process")
'-----------------------------------------------------------
'----------------------BUSCA EL PROCESO---------------------
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
'-----------------------------------------------------------
'---------SE HACE NADA---------
Set oServices = Nothing
Set oWMI = Nothing
'------------------------------
'---CAPTURA DE ERROR----
ErrHandler:
Err.Clear
'-----------------------
End Sub
Ya he conseguido que funcione.. gracias ;)
Salu2
Ranslsad
Hola,lo podes hacer con api en vez de con WMI...
saludos.