
& "!\\.\root\cimv2") 'Connect to CIMV2 Namespace Set objWMIcimv2 = GetObject("winmgmts:" _ StrTerminateThis = "notepad.exe" 'Process to terminate, 'change notepad.exe to the process you want to terminate

'-ĭim strTerminateThis As String 'The variable to hold the process to terminate ' : ***Terminating certain processes can effect the running of Windows and/or ' : ***running applications. ' : ' : ***WARNING: This will terminate a specified running process,use with caution!. ' : Uses WMI (Windows Management Instrumentation) to query all running processes ' : then terminates ALL instances of the specified process ' : held in the variable strTerminateThis. First checking to see if it is running or not. The process will terminate if you OK it, WITHOUT giving you the chance to save any changes in anything that is running in the specified process.įor example, if you typed something into notepad and ran the code 'TerminateProcess', and clicked OK to the message asking to continue, then ALL instances of notepad will close and any data held in it will be lost!. Terminating certain processes can effect the running of Windows and/or applications. The code below terminates ALL instances of a specified running process, use with caution!. The code uses WMI (Windows Management Instrumentation) to do this, so no API (Application Programming Interface) is used. If OK the code will terminate ALL instances of it. The code below will first check to see if the specified process (in the example below this is notepad.exe) is running and if it is, will ask if OK to proceed. This is held in the variable strTerminateThis. The following code needs a process in which to terminate. (To view all currently running processes on your PC, select 'Task Manager' from right-clicking on your Windows taskbar. The code below will terminate, a specific running process.

This KB entry has been tested on Excel 2000 on Windows XP Professional and also on Excel 2002 on Windows XP Home Edition. If OK to continue, the code will terminate ALL running instances of 'notepad.exe' Running, then asks wheather or not to continue with terminating ALL running instances of 'notepad.exe'. Terminates ALL running instances of a specified process by using WMI (Windows Management Instrumentation).įor example: If 'notepad.exe' was the specified process (held in variable strTerminateThis), the code first checks to see if it's
