Created
February 15, 2018 23:49
-
-
Save andreburto/39ffc0322597ac479a036a79fb8819a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Credit where it is due: | |
' http://computerperformance.co.uk/ | |
' https://msdn.microsoft.com/en-us/library/aa394372(v=vs.85).aspx | |
' ---------------------------------------------------------------------- | |
Option Explicit | |
Dim objWMIService, objShell, objProcess | |
Dim strComputer, colProcess, procName, procPath | |
procName = "notepad++.exe" | |
strComputer = "." | |
Set objWMIService = GetObject("winmgmts:!\\" & strComputer & "\root\cimv2") | |
Set colProcess = objWMIService.ExecQuery _ | |
("Select * from Win32_Process") | |
For Each objProcess in colProcess | |
If Len(objProcess.ExecutablePath) > 0 And objProcess.Name = procName Then | |
procPath = objProcess.ExecutablePath | |
objProcess.Terminate() | |
End If | |
Next | |
Set objShell = CreateObject("WScript.Shell") | |
objShell.run """"&procPath&"""", 0, false | |
WScript.Quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment