Search

VBA to Terminate Process


Below code example will Terminate firefox browser. To use this code to end other processes load your Windows task Manager and locate the process name and replace firefox.exe with your process name.



Option Explicit

Sub test_TerminateProcess()
    TerminateProcess ("firefox.exe")
End Sub
 
Function TerminateProcess(app_exe As String)

'-----------------------------
'Thanks for downloading the code. 
'Please visit our channel for a quick explainer on this code.
'Feel free to update the code as per your need and also share with your friends.
'Channel: Youtube.com/vbaa2z
'Download free codes from http://vbaa2z.blogspot.com
'Autor: L Pamai (vbaa2z.team@gmail.com)
'-----------------------------

    Dim Process As Object
    For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = '" & app_exe & "'")
        Process.Terminate
    Next
End Function

No comments:

Post a Comment

Note: only a member of this blog may post a comment.