Subscribe to Windows IT Pro
August 13, 2002 12:00 AM

Query Workstations the Easy Way

Windows IT Pro
InstantDoc ID #26054
Rating: (0)
Downloads
26054.zip

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.

Related Content:

ARTICLE TOOLS

Comments
  • brian
    9 years ago
    Feb 08, 2003

    I'm trying to work through the code but my XP system seems to have a problem with the following code in callouts B & D in Listing 1:


    >nul & if not errorlevel 1


    The program stops at these points with a syntax error. I can't seem to figure out what is going on here. Any advice?




    That is an effect of the way the code is displayed in the listing. That line you posted and the line after it needs to be concatenated instead of broken up. I tested it with Windows XP and it worked fine after that change was made.--James Adair



You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.