Reputation: 43
How to stop running application that has been executed using ShellExecute command in VB
I have tried with objShell. Quit, objShell. Kill but not satisfied. Error of ActiveX Automation: no such property or method is thrown
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute C:\Users\xyz.exe, "", ""
objShell.Kill
Upvotes: 3
Views: 594
Reputation: 2569
Your object is only opening the application, but not keeping any control of it.
One way of achieving more control is this:
Sub terminate()
Dim exeID As Double
exeID = Shell("C:\Users\xyz.exe", vbNormalFocus)
Call Shell("TaskKill /F /PID " & exeID, vbHide)
End Sub
Upvotes: 1