En un programa que tengo yo hecho para mantener segura la red lo tengo.
Arrancar con Windows:
Set PorDefecto = CreateObject("WScript.Shell")
PorDefecto.regWrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\" & app.EXEname, App.Path & "\" & App.EXEName & ".exe"
Para deshabilitar apps: Basándote en su caption, obtienes su handle y con ello el proceso, si el caption coincide con por ejemplo "Administrador de tareas de Windows" lo cierras usando su handle:
En modAPIs
'DECLARACION DE APIS
Public Declare Function GetForegroundWindow Lib "user32" () As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Yo lo hice así, añadiendo un list todas las ventanas activas...:
Private Sub timSeguridad_Timer()
'VARIABLES
Dim handle, Longitud, Retorno As Long
Dim Titulo As String
'IDENTIFICACION DE VENTANAS
handle = GetForegroundWindow()
Longitud = GetWindowTextLength(handle) + 1
Titulo = Space(Longitud)
Retorno = GetWindowText(handle, Titulo, Longitud)
Titulo = Left(Titulo, Longitud - 1)
If (Titulo <> UltimaVentana) And (Titulo <> "") Then
lstVentanas.AddItem (Titulo)
UltimaVentana = Titulo
If Comprobar(Titulo) = True Then
'SI CONTIENE PALABRAS PROHIBIDAS MANDAMOS LOS COMANDOS. CREA L FUNCION COMPROBAR QUE DIGA QUE SI EL TITULO ES "Administrador de tareas de Windows" QUE LA CIERRE
End If
End If
End Sub
¿Como cerrarla? Éste lo he sacao del www. EN un módulo
Private Declare Function OpenProcess Lib "kernel32" (ByVal _
dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject _
As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Const PROCESS_TERMINATE = &H1
Const PROCESS_QUERY_INFORMATION = &H400
Const STILL_ACTIVE = &H103
Public Sub CerrarProceso(CaptionVentana As String)
Dim hProceso As Long
Dim lEstado As Long
Dim idProc As Long
Dim winHwnd As Long
winHwnd = FindWindow(vbNullString, CaptionVentana)
If winHwnd = 0 Then
Exit Sub
End If
Call GetWindowThreadProcessId(winHwnd, idProc)
' Obtenemos el handle al proceso
hProceso = OpenProcess(PROCESS_TERMINATE Or _
PROCESS_QUERY_INFORMATION, 0, idProc)
If hProceso <> 0 Then
' Comprobamos estado del proceso
GetExitCodeProcess hProceso, lEstado
If lEstado = STILL_ACTIVE Then
' Cerramos el proceso
If TerminateProcess(hProceso, 9) <> 0 Then
Else
End If
End If
' Cerramos el handle asociado al proceso
CloseHandle hProceso
Else
Debug.Print "No se pudo tener acceso al proceso"
End If
End Sub
En un form, el que reciba los comandos..
If comando(0) = "Cerrar" Then
CerrarProceso (comando(1))
End if
Si tienes alguna duda...aki andaré