We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Public Function EndProcess(ByVal sExeName As String) As Boolean ' This works at the beginning of the program to end any processes that are still running since the last time this program ran On Error GoTo Err_Handler Dim oProcessCollection, oProcess, ok, ii Set oProcessCollection = GetObject("WinMgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & sExeName & "'") ii = oProcessCollection.Count Debug.Print "Total: " & ii If oProcessCollection.Count > 1 Then For Each oProcess In oProcessCollection ok = (oProcess.Terminate = 0) If ok Then ii = ii - 1 Debug.Print "Count: " & ii If ii = 1 Then Exit For End If End If Next End If Exit Function Err_Handler: Debug.Print Err.Description EndProcess = False End Function
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.