Terminate a running program or process

This snippet will terminate all running instances of Notepad.exe.
Set locator = CreateObject("WbemScripting.SWbemLocator")
Set service = locator.ConnectServer()
Set props = service.ExecQuery _
  ("select name, description from Win32_Process where name = 'notepad.exe'")
num = props.Count
for each notepad in props
   notepad.terminate
next



If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2010
[ home ]