Unlike Visual Basic or Microsoft Visual C++®, scripting languages, such as Visual Basic Scripting Edition (VBScript) or JScript®, do not support the use of enumerated values.
For this reason the Internet Security and Acceleration Server SDK includes two files that define as constants the enumerated values used in Forefront TMG.
The file Fpccfg.vbs defines enumerated values in VBScript format.
The file Fpccfg.js defines enumerated values in JScript format.
To use enumerated types when composing VBScript or JScript script files, copy the relevant constant definitions from the relevant Fpccfg file to the constant declarations in your code.
For example, include the following code in the declarations section of your script:
const fpcRuleActionDeny = 1 const fpcAllIpTraffic = 0 const fpcAppliesToAllContent = 0
The declaration of constants allows you to write the following:
Set root = CreateObject("FPC.Root") Dim isaArray ' An FPCArray object Dim policyRules ' An FPCPolicyRules collection Dim rule ' An FPCPolicyRule object Set isaArray = root.GetContainingArray() Set policyRules = isaArray.ArrayPolicy.PolicyRules Set rule = policyRules.AddAccessRule("Deny All Content Always Rule") rule.Action = fpcRuleActionDeny rule.AccessProperties.ProtocolSelectionMethod = fpcAppliesToAll rule.AccessProperties.AppliesToContentMethod = fpcAppliesToAllContent rule.SetAppliesAlways
If you always declare the appropriate constants in your declarations section at the beginning of each script, you can use enumerated types as you use them in C++ programs.
Alternatively, you can achieve the same effect by hard-coding the values, as shown in the following code:
Set isaArray = root.GetContainingArray() Set policyRules = isaArray.ArrayPolicy.PolicyRules Set rule = policyRules.AddAccessRule("Deny All Content Always Rule") rule.Action = 1 rule.AccessProperties.ProtocolSelectionMethod = 0 rule.AccessProperties.AppliesToContentMethod = 0 rule.SetAppliesAlways
These lines will perform the same task as the previous code lines, without the use of enumerated types.
When composing Windows script (.wsf) files that will run in a Windows Script Host environment, the constants can be included by including a reference element. The following code example, which displays the name of each network rule defined for the local computer followed by the value of its RoutingType property, shows how to include the Forefront TMG administration COM library in a .wsf file:
<job id="main"> <reference object="FPC.Root"/> <script language="VBScript"> ' Create the root object. Set root = CreateObject("FPC.Root") ' Declare the other objects needed. Dim isaArray ' An FPCArray object Dim networkRules ' An FPCNetworkRules collection Dim networkRule ' An FPCNetworkRule object ' Get references to the array object ' and the network rules collection. Set isaArray = root.GetContainingArray() Set networkRules = isaArray.NetworkConfiguration.NetworkRules ' Display the name of each network rule defined ' for the isaArray object followed by the value ' of its RoutingType property. For Each networkRule In networkRules Select Case networkRule.RoutingType Case fpcRoute WScript.Echo networkRule.Name & ": fpcRoute" Case fpcNat WScript.Echo networkRule.Name & ": fpcNat" Case Else WScript.Echo networkRule.Name & ": Unknown value" End Select Next </script> </job>
For more information, see Windows Script Host.
For more information about including type libraries containing definitions of constants in Windows script files, see Using Windows Script Files.
For information about security in Windows Script Host, see Security and Windows Script Host
Build date: 11/30/2009
© 2008 Microsoft Corporation. All rights reserved.[an error occurred while processing this directive]