Consulting

Results 1 to 2 of 2

Thread: vba to terminate Chrome Browser

  1. #1
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location

    vba to terminate Chrome Browser

    I need to be able to click a button to end Chrome.exe Process. What is the best way to accomplish this?
    I don't want it to prompt anything just close it.

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Perhaps:
    Sub FindAndTerminate(ByVal strProcName As String)   Dim objWMIService, objProcess, colProcess
       Dim strComputer
       strComputer = "."
       Set objWMIService = GetObject("winmgmts:" _
                                     & "{impersonationLevel=impersonate}!\\" _
                                     & strComputer & "\root\cimv2")
       Set colProcess = objWMIService.ExecQuery _
                        ("Select * from Win32_Process Where Name = '" & strProcName & "'")
       If colProcess.Count > 0 Then
          For Each objProcess In colProcess
             objProcess.Terminate
          Next objProcess
       End If
    End Sub
    Called with:
    FindAndTerminate "chrome.exe"
    Be as you wish to seem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •