The following script illustrates how you might include the elements described in the previous sections of this appendix to fully "document" a script. Although documenting a script does add considerably to its length, it also makes the script easier to understand when you need to modify it at a later date.
' +++++++++++++++++++++++++++++++++++++++++++++++++++++
' Written by Ed Wilson, 7/13/2006' version 1.0 basic script
' version 1.1 -- added additional documention, 1/14/2006
' Key concepts are listed below:
' This script displays various Computer Names by reading
' the registry
' ++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option Explicit
On Error Resume Next
Dim objShell 'holds connection to wscript.shell
Dim regActiveComputerName 'holds registry string for
'active computer name
Dim regComputerName 'holds registry string for computer name
Dim regHostname 'holds registry string for hostname
Dim ActiveComputerName 'holds value found in registry
Dim ComputerName 'holds value found in registry
Dim Hostname 'holds value found in registry
regActiveComputerName = "HKLM\SYSTEM\CurrentControlSet" & _
"\Control\ComputerName\ActiveComputerName\ComputerName"
regComputerName = "HKLM\SYSTEM\CurrentControlSet\Control" & _
"\ComputerName\ComputerName\ComputerName"
regHostname = "HKLM\SYSTEM\CurrentControlSet\Services" & _
"\Tcpip\Parameters\Hostname"
Set objShell = CreateObject("WScript.Shell") 'provides access to regRead
ActiveComputerName = objShell.RegRead(regActiveComputerName)
ComputerName = objShell.RegRead(regComputerName)
Hostname = objShell.RegRead(regHostname)
'WScript.Echo is simple output. The output variables are assigned value in
'the worker section due to the regRead method.
WScript.Echo activecomputername & " is active computer name"
WScript.Echo ComputerName & " is computer name"
WScript.Echo Hostname & " is host name"