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:
- In the sample process.txt file, delete all the entries except WINWORD.EXE.
- Make sure Word isn't running on your computer.
- Run CheckProcess .hta. In the utility's UI, WINWORD.EXE's Status column should read DOWN.
- Start Word.
- 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.
Magni Mauro