How to Add Operations
Adding operations to Chkws is simple. You just need to modify four areas:
- In the code at callout A, add the operation's keyword.
- In the code at callout B, add code that checks for any required utilities. (If no utilities are required, this modification isn't necessary.)
- In the Work subroutine at callout D, add an If command that performs the operation.
- In the Syntax subroutine, add the keyword and description of the operation.
For example, suppose you want to add an operation that determines the service pack level installed on each workstation. First, you add a keyword such as spver to the list of valid keywords contained in the second line of callout A. The code would then read
echo uptime ie_ver spver |
find /i "%2" >nul & if
errorlevel 1 goto SYNTAX
Checking the service pack level requires the use of reg.exe. Because the script already determines that reg.exe exists, you can simply insert the %SPVER% environment variable in the reg.exe code at callout B. The resulting code looks like
echo. %IE_VER% %SPVER% |
find "Y" >nul & if not
errorlevel 1
if not exist %UTILS%\reg.exe
goto NOREG
The line that actually does the work will be inserted at callout D and look like
if .%SPVER%.==.Y. for /f
"skip=4 delims=Z tokens=2*"
%%v in ('%UTILS%\reg query
"\\%1\HKLM\Software\Microsoft Windows NT\CurrentVersion"
/v CSDVersion') do echo
%1,%%v
>>"%TEMP%\report.txt"
Finally, in the Syntax subroutine, you add the operation's keyword and description. The code to add is
echo SPVER (checks
service pack level)
Make the Investment
Nearly any type of workstation query can be incorporated into Chkws, even queries that use VBScript, Windows Script Host (WSH), or Perl files. The investment in time to get Chkws working in your network environment will pay off down the line.