VBScript Essentials


The basis of scripting requires some familiarity with object-oriented programming (OOP), and terms such as objects, properties, and methods. These elements are the building blocks we use when we want to write a script not only for ISA Server, but for any script. The most essential element is an object, which can have one or more properties and one or more methods. To illustrate how these items relate to something we all know, think of a person (the object in this example). A person can have a first name, last name, and age, which are like properties. If a person needs to change his or her last name, he or she needs a method to do so.

Table 12-1 shows the basic terminology of scripting objects.

Table 12-1: Script Terminology

Name

Description

Example

Variable

A variable is a temporary place to hold data in a program. It is declared with the Dim statement.

 Dim objRoot 

Object

Objects are reusable software components that contain properties and methods and can be called by applications to perform certain tasks.

 Set objRoot = CreateObject("FPC.Root") 

Property

A property is either a value or a characteristic that is held by an object.

 FPCComputer.Description = "Server" 

Method

A method is a command that performs an action.

 objFPCComputers.Save 

Sub

A sub procedure is a part of code that does not return any value.

 Sub WriteIT(value)   Wscript.Echo value End Sub 

Function

A function procedure is a part of code and can return a value.

 Function TrimIT(value)  TrimIT = Trim(value) End Function 

When writing scripts against ISA Server you need to know what objects, properties, and methods the ISA server exposes and how to access and control them. Information on how to write scripts is included in the SDK for ISA Server 2004. We take a closer look at the ISA Server 2004 SDK as we are writing the scripts.

Tip 

You can download the ISA Server 2004 SDK from http://go.microsoft.com/?linkid=2392254. The SDK can be used with both Standard Edition and Enterprise Edition.

Note that the naming convention used in all the samples is built on the object type prefix, and then the name of the COM object. This convention makes it easier to search the SDK for more information. An example of this naming convention would be objRoot, where obj is the prefix for an object and Root is the object itself. Table 12-2 illustrates other commonly used prefixes in VBScript.

Table 12-2: Common Naming Prefixes

Type

Prefix

Example

Boolean

bln

blnFound

Date

dtm

dtmStartTime

Integer

int

intCounter

Object

obj

objRoot

String

str

strComputerName




Microsoft Internet Security and Acceleration ISA Server 2004 Administrator's Pocket Consultant
Microsoft Internet Security and Acceleration (ISA) Server 2004 Administrators Pocket Consultant (Pro-Administrators Pocket Consultant)
ISBN: 0735621888
EAN: 2147483647
Year: 2006
Pages: 173

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net