Utility Monitors Crucial Processes


I created the CheckProcess utility to monitor crucial processes on a local or remote computer. The utility is composed of two files: CheckProcess.hta, which provides the browser-based UI, and process.txt, which specifies the processes to monitor. You can download CheckProcess.hta and a sample process.txt file from the Windows Scripting Solutions Web site.

To use this utility, you must know the names of all the processes that you want to monitor and insert those names in process.txt. If you're unsure of the names, you can start those processes on your computer, then place your cursor in a blank area on the taskbar and right-click. In the menu that appears, select Task Manager. In the Windows Task Manager dialog box, select the Processes tab. On this tab, you'll find the names of the running processes in the Image Name column. Process names are case sensitive, so you must insert the names as you see them in the Image Name column. Figure 1 shows a sample process.txt file.

After you've customized the process.txt file, create a folder on your hard disk and place CheckProcess.hta and the customized process.txt file in that folder. Double-clicking CheckProcess.hta will bring up a UI similar to the one that Figure 2 shows.

The CheckProcess utility checks every 1000 milliseconds (1 second) to see whether the processes specified in process.txt file are running. When the process is running, the Status column reads UP. When the process isn't running, the Status column reads DOWN and the cell's background color changes to red.

You can change the default refresh value (i.e., 1000 milliseconds) to a different value by editing CheckProcess.hta. Open this file in Notepad and look for the line

refrTime = 1000 

If you want the utility to refresh every 2 seconds, change the 1000 value to 2000.

To check the status of processes on a remote computer, you need to change one line in CheckProcess.hta. Change the line

strComputer = "." 


strComputer = "remote_computer" 

where remote_computer is the remote computer's hostname (e.g., remote001). You must have the rights to execute the utility on a remote computer.

The CheckProcess utility is able to constantly check the status of processes because of the setInterval method of the Dynamic HTML (DHTML) Windows object. This method evaluates an expression every time the specified number of milliseconds elapses. The method's syntax is

Window.setInterval(exp, delay) 

where exp is the expression and delay is the number of milliseconds. In this case, the expression being evaluated is code that executes a subroutine named checkres.

The checkres subroutine uses the standard Windows Management Instrumentation (WMI) statement objWMIService.ExecQuery to prepare VBScript to execute the query

"Select * from Win32_process" 

This query retrieves the names of all the running processes. The subroutine then compares the query's list of running processes against the process.txt file's list of crucial processes. When a process is on both lists, the subroutine lists the process's name and displays its status as UP. When a process is on the process.txt file's list but not on the query's list, the subroutine lists the process's name and displays its status as DOWN. When a process is on the query's list but not on the process.txt file's list, the subroutine doesn't display any information.

The checkres subroutine also uses a function named userinfo. This function uses Windows Script Host's (WSH's) WScript.Network object to retrieve the username and computer name. This object lets you easily access shared resources on Windows networks.

If you have Microsoft Word installed on your local computer, you can test the utility by following these steps:

  1. In the sample process.txt file, delete all the entries except WINWORD.EXE.
  2. Make sure Word isn't running on your computer.
  3. Run CheckProcess .hta. In the utility's UI, WINWORD.EXE's Status column should read DOWN.
  4. Start Word.
  5. Run CheckProcess.hta. WINWORD.EXE's Status column should now read UP.

You can customize this utility so that it performs a specific action when a process goes down. For example, when a process goes down, you can add code that displays an alert box, sends an email, or restarts the process. Listing 2 shows where you can add such code.

The CheckProcess utility works on Windows XP, Windows 2000, and Win2K Professional machines that have WSH 5.6 installed. To verify the WSH version on your machine, run the command

cscript //Logo 

from the command line. The first line in the output will show the WSH version.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.