Managing content delivery settings

Web traffic may contain malware (such as worms, viruses, and spyware). Microsoft Forefront Threat Management Gateway includes malware inspection for scanning, cleaning, and blocking harmful HTTP content and files. When malware inspection is enabled, downloaded Web pages and files allowed by access rules may be inspected for malware.

Because malware inspection may cause some delay in the delivery of content from the server to the client, Forefront TMG trickles portions of the content as file or alternatively, sends progress notifications for specified types of files to reassure the user during this delay.

Trickling refers to sending small portions of a file to the client application. This is done while the file is being inspected for malware. Trickling helps prevent the client application from reaching a time-out limit before the entire content is downloaded and inspected, which in turn improves the user experience. The portions sent to the client must be very small to minimize the risk of infection because a portion of content may contain malicious content that can be detected only when a subsequent portion of the data is inspected. Trickling is performed for all types of files that are not specified for progress notifications.

When downloading a large file, Forefront TMG trickles the content to the client as the file is scanned to prevent the application from timing out and the user from canceling the download due to a lack of interaction. When a file is trickled, Forefront TMG begins downloading an initial minimal portion of the file from the remote location, inspects and delivers this minimal portion, and then continues to download, inspect, and deliver the remainder of the file.

Cleaning is possible only if the file is inspected before passing the content to the client. In the case of trickling, it is not possible to clean the file or replace it with a text notification.

If an infection is detected in a file that is being trickled, Forefront TMG resets the connection and does not pass the remaining chunks to the client.

When progress notifications are sent, instead of trickling the requested content during malware inspection, Forefront TMG sends an HTML page to the client. This page informs the user that the requested content is being inspected and displays an indicator of the download and inspection progress. After download and inspection of the content are completed, the page informs the user that the content is ready and displays a button for downloading the content.

If a file is found to be infected during malware inspection and the file is successfully cleaned, Forefront TMG sends the scanned file to the client. If the file cannot be cleaned, Forefront TMG sends an HTML page notifying the user that the file was found to be infected and has been blocked. Such a file is purged immediately from the temporary storage. All cached portions associated with this file are either purged or marked as infected.

If a user clicks a link for downloading an executable file with the .exe file name extension on a Web page in Internet Explorer and then clicks Save, the Save As dialog box opens with details for the HTML notification page.

The content delivery settings that can be configured in Forefront TMG Management include the following:

  • Enabling or disabling the sending of progress notifications for the specified types of content.
  • A list of the MIME content types and file name extensions for which progress notifications are used when the sending of progress notifications is enabled.

In addition, several time periods that control the content delivery process and several settings that control trickling can be configured programmatically.

The content delivery times are summarized in the following table.

Setting Description

Delivery delay

Specifies the time, in seconds, before Forefront TMG starts delivering content when the content is trickled. Its default value is 10 seconds, and its range of permissible values is from 0 through 4,294,967.

Progress refresh delay

Specifies the time, in seconds, before the progress information is refreshed and sent to the client. Its default value is 5 seconds, and its range of permissible values is from 0 through 4,294,967.

Maximum retrieval time

Specifies the maximum time, in seconds, during which inspected content will be available for retrieval after the Download button appears when progress notifications are sent to the client. Its default value is 43,200 seconds (12 hours), and its range of permissible values is from 0 through 4,294,967.

Maximum repeated retrieval time

Specifies the maximum time, in seconds, during which inspected content will be available for repeated retrieval after the Download button appears when progress notifications are sent to the client. Its default value is 300 seconds (5 minutes), and its range of permissible values is from 0 through 4,294,967.

The trickling settings are summarized in the following table.

Setting Description

Delivery delay

Specifies the time, in seconds, before Forefront TMG starts delivering content when the content is trickled. Its default value is 10 seconds, and its range of permissible values is from 0 through 4,294,967.

Standard trickling initial size

Specifies the size of the first portion of the content sent to the client when standard trickling is used. Its default value is 4096 bytes, and its range of permissible values is from 1 through 65,536.

Standard trickling size

Specifies the size of subsequent portions of the content sent to the client after the first portion when standard trickling is used. Its default value is 50 bytes, and its range of permissible values is from 1 through 65,536.

Standard trickling interval

Specifies the time interval, in seconds, between successive portions, sent to the client when standard trickling is used. Its default value is 50 seconds, and its range of permissible values is from 1 through 65,536.

Fast trickling mode

Specifies a number that defines the tradeoff between user experience and performance for fast trickling. Its default value is 1, and its range of permissible values is from 0 through 3.

Showing the content delivery times

The Microsoft Visual Basic Scripting Edition (VBScript) code in ShowContentDeliveryTimes.vbs (listed later in this document) displays the times that control the delivery of content during malware inspection in the local array.

This script, as presented, must be run on a Forefront TMG computer with the Microsoft Firewall service installed, but it can be modified to run on a remote management computer.

To use this script, paste the code in the script listing into a text editor, save it in a file named ShowContentDeliveryTimes.vbs, and run it from a command prompt.

Usage:

CScript ShowContentDeliveryTimes.vbs

To show the content delivery times

  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other Forefront TMG administration COM objects.

  2. Get references to the FPCArray object and the FPCContentDeliverySettings object for the local array.

  3. Display the values of the DeliveryDelay, ProgressRefreshDelay, ProgressNotificationContentRetrievalTimeout, and ProgressNotificationRepeatedRetrievalTimeout properties of the FPCContentDeliverySettings object.

Script listing: ShowContentDeliveryTimes.vbs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright (c) Microsoft Corporation. All rights reserved.
' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE
' ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE     
' REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR
' WITHOUT MODIFICATION, IS HEREBY PERMITTED.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script displays the following settings for content delivery
' during malware inspection in the local array:
'   Delivery delay - the time, in seconds, before starting content
'       delivery when the content is trickled
'   Progress refresh delay - the time, in seconds, before refreshing
'       progress information
'   Maximum retrieval time - the maximum time, in seconds, during which
'       inspected content will be available for retrieval after the
'       Download button appears when progress notifications are sent
'   Maximum repeated retrieval time - the maximum time, in seconds, 
'       during which inspected content will be available for repeated 
'       retrieval after the Download button appears when progress 
'       notifications are sent
' This script can be run from a command prompt by entering the 
' following command:
'     CScript ShowContentDeliveryTimes.vbs
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

Sub ShowContentDeliverySettings()

    ' Declare the objects needed.
    Dim root         ' The FPCLib.FPC root object
    Dim tmgArray     ' An FPCArray object
    Dim cdSettings   ' An FPCContentDeliverySettings object

    ' Create the root object.
    Set root = CreateObject("FPC.Root")

    ' Get references to the array object 
    ' and the content delivery settings object.
    Set tmgArray = root.GetContainingArray()
    Set cdSettings = _
        tmgArray.MalwareInspectionSettings.ContentDeliverySettings

    WScript.Echo "Delivery delay:                  " _
        & cdSettings.DeliveryDelay & " seconds"
    WScript.Echo "Progress refresh delay:          " _
        & cdSettings.ProgressRefreshDelay & " seconds"
    WScript.Echo "Maximum retrieval time:  " _
        & cdSettings.ProgressNotificationContentRetrievalTimeout _
        & " seconds"
    WScript.Echo "Maximum repeated retrieval time: " _
        & cdSettings.ProgressNotificationRepeatedRetrievalTimeout _
        & " seconds"
End Sub
ShowContentDeliverySettings()

Modifying the content delivery times

The VBScript code in SetContentDeliveryTimes.vbs (listed later in this document) configures the times that control the delivery of content during malware inspection in the local array.

This script, as presented, must be run on a Forefront TMG computer with the Microsoft Firewall service installed, but it can be modified to run on a remote management computer.

To use this script, paste the code in the script listing into a text editor, save it in a file named SetContentDeliveryTimes.vbs, and then run it from a command prompt.

Usage:

CScript SetContentDeliveryTimes.vbs [/d] [/dd:value] [/pd:value] [/rt:value] [/rrt:value] [/h | /?]

Here value specifies the value supplied for the applicable argument. The meanings of the arguments are summarized in the following table.

Argument Meaning

/d

Restore the default values of the delivery delay, progress refresh delay, maximum retrieval time, and maximum repeated retrieval time.

/dd

Set the delivery delay to the value specified in value.

/pd

Set the progress refresh delay to the value specified in value.

/rt

Set the maximum retrieval time to the value specified in value.

/rrt

Set the maximum repeated retrieval time to the value specified in value.

/h /?

Display the usage information.

After you run the script, check the Configuration tab for the Monitoring node to verify that the changes were applied.

To set the content delivery times

  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other Forefront TMG administration COM objects.

  2. Get references to the FPCArray object and the FPCContentDeliverySettings object for the local array.

  3. Do one of the following:

    • If the /d argument is specified, restore the default values of the DeliveryDelay, ProgressRefreshDelay, ProgressNotificationContentRetrievalTimeout, and ProgressNotificationRepeatedRetrievalTimeout properties of the FPCContentDeliverySettings object.
    • If the /d argument is not specified, change the values of the DeliveryDelay, ProgressRefreshDelay, ProgressNotificationContentRetrievalTimeout, and ProgressNotificationRepeatedRetrievalTimeout properties of the FPCContentDeliverySettings object to the values specified by the user.
  4. Call Save on the FPCContentDeliverySettings object to write the changes to persistent storage.

Script listing: SetContentDeliveryTimes.vbs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright (c) Microsoft Corporation. All rights reserved.
' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE
' ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE     
' REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR
' WITHOUT MODIFICATION, IS HEREBY PERMITTED.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script configures the following settings for content delivery
' during malware inspection in the local array:
'   Delivery delay - the time, in seconds, before starting content
'       delivery when the content is trickled
'   Progress refresh delay - the time, in seconds, before refreshing
'       progress information
'   Maximum retrieval time - the maximum time, in seconds, during which
'       inspected content will be available for retrieval after the
'       Download button appears when progress notifications are sent
'   Maximum repeated retrieval time - the maximum time, in seconds, 
'       during which inspected content will be available for repeated
'       retrieval after the Download button appears when progress
'       notifications are sent
' This script can be run from a command prompt by entering the 
' following command:
'     CScript SetContentDeliveryTimes.vbs [/d] [/dd:value]
'     [/pd:value] [/rt:value] [/rrt:value] [/h | /?]
' After you run the script, check the Configuration tab for the
' Monitoring node to verify that the changes were applied.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

Main(WScript.Arguments)

Sub Main(args)
    Dim argsN        ' A WScript.Arguments.Named object
    Dim num          ' An Integer

    Set argsN = args.Named 
    num = 0
    If argsN.Exists("d") Then
        num = num + 1
    End If
    If argsN.Exists("dd") Then
        num = num + 1
    End If
    If argsN.Exists("pd") Then
        num = num + 1
    End If
    If argsN.Exists("rt") Then
        num = num + 1
    End If
    If argsN.Exists("rrt") Then
        num = num + 1
    End If
    If argsN.Exists("h") Then
        num = num + 1
    End If
    If argsN.Exists("?") Then
        num = num + 1
    End If
    If argsN.Count <> args.Count Or argsN.Count <> num Then
        WScript.Echo "An invalid argument was entered."
        Usage()
    End If

    If argsN.Exists("h") And argsN("h") <> "" Then
        WScript.Echo "An invalid argument value was provided."
        Usage()
    End If
    If argsN.Exists("?") And argsN("?") <> "" Then
        WScript.Echo "An invalid argument value was provided."
        Usage()
    End If
    If argsN.Exists("h") Or argsN.Exists("?") Or args.Count = 0 Then
        Usage()
    End If
    If argsN.Exists("d") Then
        If args.Count > 1 Then
            WScript.Echo "Only the default settings will be restored."
            WScript.Echo "The other arguments will be ignored."
        End If
        ResetDefaults()
    End If
    If argsN.Exists("d") And argsN("d") <> "" Then
        WScript.Echo "An invalid argument value was provided."
        Usage()
    End If
    If argsN.Exists("dd") And argsN("dd") = "" Then
        WScript.Echo "No value was provided for /dd."
        Usage()
    End If
    If argsN.Exists("pd") And argsN("pd") = "" Then
        WScript.Echo "No value was provided for /pd."
        Usage()
    End If
    If argsN.Exists("rt") And argsN("rt") = "" Then
        WScript.Echo "No value was provided for /rt."
        Usage()
    End If
    If argsN.Exists("rrt") And argsN("rrt") = "" Then
        WScript.Echo "No value was provided for /rrt."
        Usage()
    End If

    SetContentDeliverySettings(argsN)
End Sub

Sub SetContentDeliverySettings(argsN)

    ' Declare the objects needed.
    Dim root         ' The FPCLib.FPC root object
    Dim tmgArray     ' An FPCArray object
    Dim cdSettings   ' An FPCContentDeliverySettings object

    ' Creae the root object.
    Set root = CreateObject("FPC.Root")

    ' Get references to the array object 
    ' and the content delivery settings object.
    Set tmgArray = root.GetContainingArray()
    Set cdSettings = _
        tmgArray.MalwareInspectionSettings.ContentDeliverySettings

    If argsN.Exists("dd") And argsN("dd") <> "" Then
        WScript.Echo "Current delivery delay: " _
            & cdSettings.DeliveryDelay
        WScript.Echo "Setting the delivery delay to " _
            & argsN("dd") & " seconds ..."
        cdSettings.DeliveryDelay = argsN("dd")
    End If

    If argsN.Exists("pd") And argsN("pd") <> "" Then
        WScript.Echo "Current progress refresh delay: " _
            & cdSettings.ProgressRefreshDelay
        WScript.Echo "Setting the progress refresh delay to " _
            & argsN("pd") & " seconds ..."
        cdSettings.ProgressRefreshDelay = argsN("pd")
    End If

    If argsN.Exists("rt") And argsN("rt") <> "" Then
        WScript.Echo "Current maximum retrieval time: " _
            & cdSettings.ProgressNotificationContentRetrievalTimeout
        WScript.Echo "Setting the maximum retrieval time to " _
            & argsN("rt") & " seconds ..."
        cdSettings.ProgressNotificationContentRetrievalTimeout = _
            argsN("rt")
    End If

    If argsN.Exists("rrt") And argsN("rrt") <> "" Then
        WScript.Echo "Current maximum repeated retrieval time: " _
            & cdSettings.ProgressNotificationRepeatedRetrievalTimeout
        WScript.Echo "Setting the maximum repeated retrieval time " _
            & "to " & argsN("rrt") & " seconds ..."
        cdSettings.ProgressNotificationRepeatedRetrievalTimeout = _
            argsN("rrt")
    End If

    WScript.Echo  "Saving ..."
    cdSettings.Save
    WScript.Echo "Done!"
End Sub

Sub ResetDefaults()

    ' Declare constants needed
    Const defaultDeliveryDelay = 10
    Const defaultProgressRefreshDelay = 5
    Const defaultRetrievalTimeout = 43200
    Const defaultRepeatedRetrievalTimeout = 300

    ' Declare the objects needed.
    Dim root         ' The FPCLib.FPC root object
    Dim tmgArray     ' An FPCArray object
    Dim cdSettings   ' An FPCContentDeliverySettings object

    ' Create the root object.
    Set root = CreateObject("FPC.Root")

    ' Get references to the array object 
    ' and the content delivery settings object.
    Set tmgArray = root.GetContainingArray()
    Set cdSettings = _
        tmgArray.MalwareInspectionSettings.ContentDeliverySettings

    WScript.Echo "Setting the delivery delay to " _
        & defaultDeliveryDelay & " seconds (the default) ..."
    cdSettings.DeliveryDelay = defaultDeliveryDelay
    WScript.Echo "Setting the progress refresh delay to " _
        & defaultProgressRefreshDelay & " seconds (the default) ..."
    cdSettings.ProgressRefreshDelay = defaultProgressRefreshDelay
    WScript.Echo "Setting the maximum retrieval time to " _
        & defaultRetrievalTimeout & " seconds (the default) ..."
    cdSettings.ProgressNotificationContentRetrievalTimeout = _
        defaultRetrievalTimeout
    WScript.Echo "Setting the maximum repeated retrieval time to " _
        & defaultRepeatedRetrievalTimeout _
        & " seconds (the default) ..."
    cdSettings.ProgressNotificationRepeatedRetrievalTimeout = _
        defaultRepeatedRetrievalTimeout

    WScript.Echo  "Saving ..."
    cdSettings.Save
    WScript.Echo "Done!"
    WScript.Quit
End Sub

Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  " & WScript.ScriptName & " [/d] [/dd:value] " _
        & "[/pd:value] [/rt:value] [/rrt:value] [/h | /?]" & VbCrLf _
        & "" & VbCrLf _
        & "    /d   - Restore the default values" & VbCrLf _
        & "    /dd  - Set delivery delay" & VbCrLf _
        & "    /pd  - Set progress notification delay" & VbCrLf _
        & "    /rt  - Set maximum retrieval time " & VbCrLf _ 
        & "    /rrt - Set maximum repeated retrieval time " & VbCrLf _ 
        & "    value - New property value, in seconds" & VbCrLf _
        & "    /h /? - Display this help."
    WScript.Quit
End Sub

Showing the trickling settings

The VBScript code in ShowTricklingSettings.vbs (listed later in this document) displays the configuration settings that control trickling during malware inspection in the local array.

This script, as presented, must be run on a Forefront TMG computer with the Microsoft Firewall service installed, but it can be modified to run on a remote management computer.

To use this script, paste the code in the script listing into a text editor, save it in a file named ShowTricklingSettings.vbs, and then run it from a command prompt.

Usage:

CScript ShowTricklingSettings.vbs

To show the trickling settings

  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other Forefront TMG administration COM objects.

  2. Get references to the FPCArray object and the FPCContentDeliverySettings object for the local array.

  3. Display the values of the DeliveryDelay, StandardTricklingInitialSize, StandardTricklingSize, StandardTricklingInterval, and FastTricklingMode properties of the FPCContentDeliverySettings object.

Script listing: ShowTricklingSettings.vbs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright (c) Microsoft Corporation. All rights reserved.
' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE
' ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE     
' REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR
' WITHOUT MODIFICATION, IS HEREBY PERMITTED.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script displays the following settings for trickling during
' malware inspection in the local array:
'   Delivery delay - the time, in seconds, before starting content
'       delivery when the content is trickled
'   Standard trickling initial size - size of the first portion of the
'       content sent to the client when standard trickling is used
'   Standard trickling size - the size of subsequent portions of the
'       content sent to the client when standard trickling is used
'   Standard trickling interval - time interval, in seconds, between
'       successive portions, sent to the client when standard trickling
'       is used
'   Fast trickling mode - a number that specifies the tradeoff between
'       user experience and performance for fast trickling
' This script can be run from a command prompt by entering the 
' following command:
'     CScript ShowTrickling.vbs
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

Sub ShowTricklingSettings()

    ' Declare the objects needed.
    Dim root         ' The FPCLib.FPC root object
    Dim tmgArray     ' An FPCArray object
    Dim cdSettings   ' An FPCContentDeliverySettings object

    ' Create the root object.
    Set root = CreateObject("FPC.Root")

    ' Get references to the array object 
    ' and the content delivery settings object.
    Set tmgArray = root.GetContainingArray()
    Set cdSettings = _
        tmgArray.MalwareInspectionSettings.ContentDeliverySettings

    WScript.Echo "Delivery delay:                  " _
        & cdSettings.DeliveryDelay & " seconds"
    WScript.Echo "Standard trickling initial size: " _
        & cdSettings.StandardTricklingInitialSize & " bytes"
    WScript.Echo "Standard trickling size:         " _
        & cdSettings.StandardTricklingSize & " bytes"
    WScript.Echo "Standard trickling interval:     " _
        & cdSettings.StandardTricklingInterval & " seconds"
    WScript.Echo "Fast trickling mode (0 - 3):     " _
        & cdSettings.FastTricklingMode
End Sub

ShowTricklingSettings()

Modifying the trickling settings

The VBScript code in SetTricklingSettings.vbs (listed later in this document) configures the configuration settings that control trickling during malware inspection in the local array.

This script, as presented, must be run on a Forefront TMG computer with the Microsoft Firewall service installed, but it can be modified to run on a remote management computer.

To use this script, paste the code in the script listing into a text editor, save it in a file named SetTricklingSettings.vbs, and then run it from a command prompt.

Usage:

CScript SetTricklingSettings.vbs [/d] [/dd:value] [/sis:value]

[/ss:value] [/ti:value] [/ftm:value] [/h | /?]

Here value specifies the value supplied for the applicable argument. The meanings of the arguments are summarized in the following table.

Argument Meaning

/d

Restore the default values of the delivery delay, progress refresh delay, maximum retrieval time, and maximum repeated retrieval time.

/dd

Set the delivery delay to the value specified in value.

/sis

Set the standard trickling initial size to the value specified in value.

/ss

Set the standard trickling size to the value specified in value.

/ti

Set the standard trickling interval to the value specified in value.

/ftm

Set the fast trickling mode to the value specified in value.

/h /?

Display the usage information.

After you run the script, check the Configuration tab for the Monitoring node to verify that the changes were applied.

To modify the trickling settings

  1. Create an instance of the FPC COM object, which is known as the root object and provides access to the other Forefront TMG administration COM objects.

  2. Get references to the FPCArray object and the FPCContentDeliverySettings object for the local array.

  3. Do one of the following:

    • If the /d argument is specified, restore the default values of the DeliveryDelay, StandardTricklingInitialSize, StandardTricklingSize, StandardTricklingInterval, and FastTricklingMode properties of the FPCContentDeliverySettings object.
    • If the /d argument is not specified, change the values of the DeliveryDelay, StandardTricklingInitialSize, StandardTricklingSize, StandardTricklingInterval, and FastTricklingMode properties of the FPCContentDeliverySettings object to the values specified by the user.
  4. Call Save on the FPCContentDeliverySettings object to write the changes to persistent storage.

Script listing: SetTricklingSettings.vbs

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright (c) Microsoft Corporation. All rights reserved.
' THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE
' ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE     
' REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR
' WITHOUT MODIFICATION, IS HEREBY PERMITTED.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This script configures the following settings for trickling during
' malware inspection in the local array:
'   Delivery delay - the time, in seconds, before starting content
'       delivery when the content is trickled
'   Standard trickling initial size - size of the first portion of the
'       content sent to the client when standard trickling is used
'   Standard trickling size - the size of subsequent portions of the
'       content sent to the client when standard trickling is used
'   Standard trickling interval - time interval, in seconds, between
'       successive portions, sent to the client when standard trickling
'       is used
'   Fast trickling mode - a number that specifies the tradeoff between
'       user experience and performance for fast trickling
' This script can be run from a command prompt by entering the 
' following command:
'     CScript SetTricklingSettings.vbs [/d] [/dd:value] [/sis:value]
'     [/ss:value] [/ti:value] [/ftm:value] [/h | /?]
' After you run the script, check the Configuration tab for the
' Monitoring node to verify that the changes were applied.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit

Main(WScript.Arguments)

Sub Main(args)
    Dim argsN        ' A WScript.Arguments.Named object
    Dim num          ' An Integer

    Set argsN = args.Named 

    num = 0
    If argsN.Exists("d") Then
        num = num + 1
    End If
    If argsN.Exists("dd") Then
        num = num + 1
    End If
    If argsN.Exists("sis") Then
        num = num + 1
    End If
    If argsN.Exists("ss") Then
        num = num + 1
    End If
    If argsN.Exists("ti") Then
        num = num + 1
    End If
    If argsN.Exists("ftm") Then
        num = num + 1
    End If
    If argsN.Exists("h") Then
        num = num + 1
    End If
    If argsN.Exists("?") Then
        num = num + 1
    End If
    If argsN.Count <> args.Count Or argsN.Count <> num Then
        WScript.Echo "An invalid argument was entered."
        Usage()
    End If

    If argsN.Exists("h") And argsN("h") <> "" Then
        WScript.Echo "An invalid argument value was provided."
        Usage()
    End If
    If argsN.Exists("?") And argsN("?") <> "" Then
        WScript.Echo "An invalid argument value was provided."
        Usage()
    End If
    If argsN.Exists("h") Or argsN.Exists("?") Or args.Count = 0 Then
        Usage()
    End If
    If argsN.Exists("d") Then
        If args.Count > 1 Then
            WScript.Echo "Only the default settings will be restored."
            WScript.Echo "The other arguments will be ignored."
        End If
        ResetDefaults()
    End If
    If argsN.Exists("d") And argsN("d") <> "" Then
        WScript.Echo "An invalid argument value was provided."
        Usage()
    End If
    If argsN.Exists("dd") And argsN("dd") = "" Then
        WScript.Echo "No value was provided for /dd."
        Usage()
    End If
    If argsN.Exists("sis") And argsN("sis") = "" Then
        WScript.Echo "No value was provided for /sis."
        Usage()
    End If
    If argsN.Exists("ss") And argsN("ss") = "" Then
        WScript.Echo "No value was provided for /ss."
        Usage()
    End If
    If argsN.Exists("ti") And argsN("ti") = "" Then
        WScript.Echo "No value was provided for /ti."
        Usage()
    End If
    If argsN.Exists("ftm") And argsN("ftm") = "" Then
        WScript.Echo "No value was provided for /ftm."
        Usage()
    End If

    SetTrickling(argsN)
End Sub

Sub SetTrickling(argsN)

    ' Declare the objects needed.
    Dim root         ' The FPCLib.FPC root object
    Dim tmgArray     ' An FPCArray object
    Dim cdSettings   ' An FPCContentDeliverySettings object

    ' Create the root object.
    Set root = CreateObject("FPC.Root")

    ' Get references to the array object 
    ' and the content delivery settings object.
    Set tmgArray = root.GetContainingArray()
    Set cdSettings = _
        tmgArray.MalwareInspectionSettings.ContentDeliverySettings

    If argsN.Exists("dd") And argsN("dd") <> "" Then
        WScript.Echo "Current delivery delay: " _
            & cdSettings.DeliveryDelay
        WScript.Echo "Setting the delivery delay to " _
            & argsN("dd") & " seconds ..."
        cdSettings.DeliveryDelay = argsN("dd")
    End If

    If argsN.Exists("sis") And argsN("sis") <> "" Then
        WScript.Echo "Current standard trickling initial size: " _
            & cdSettings.StandardTricklingInitialSize
        WScript.Echo "Setting the standard trickling initial size " _
            & " to " & argsN("sis") & " bytes ..."
        cdSettings.StandardTricklingInitialSize = argsN("sis")
    End If

    If argsN.Exists("ss") And argsN("ss") <> "" Then
        WScript.Echo "Current standard trickling size: " _
            & cdSettings.StandardTricklingSize
        WScript.Echo "Setting the standard trickling size to " _
            & argsN("ss") & " bytes ..."
        cdSettings.StandardTricklingSize = _
            argsN("ss")
    End If

    If argsN.Exists("ti") And argsN("ti") <> "" Then
        WScript.Echo "Current standard trickling interval: " _
            & cdSettings.StandardTricklingInterval
        WScript.Echo "Setting the standard trickling interval to " _
            & argsN("ti") & " seconds ..."
        cdSettings.StandardTricklingInterval = _
            argsN("ti")
    End If

    If argsN.Exists("ftm") And argsN("ftm") <> "" Then
        WScript.Echo "Current fast trickling mode: " _
            & cdSettings.FastTricklingMode
        WScript.Echo "Setting the fast trickling mode to " _
            & argsN("ftm") & " ..."
        cdSettings.FastTricklingMode = _
            argsN("ftm")
    End If

    WScript.Echo  "Saving ..."
    cdSettings.Save
    WScript.Echo "Done!"
End Sub

Sub ResetDefaults()

    ' Declare constants needed
    Const defaultDeliveryDelay = 10
    Const defaultStandardTricklingInitialSize = 4096
    Const defaultStandardTricklingSize = 50
    Const defaultStandardTricklingInterval = 5
    Const defaultFastTricklingMode = 1

    ' Declare the objects needed.
    Dim root         ' The FPCLib.FPC root object
    Dim tmgArray     ' An FPCArray object
    Dim cdSettings   ' An FPCContentDeliverySettings object

    ' Create the root object.
    Set root = CreateObject("FPC.Root")

    ' Get references to the array object 
    ' and the content delivery settings object.
    Set tmgArray = root.GetContainingArray()
    Set cdSettings = _
        tmgArray.MalwareInspectionSettings.ContentDeliverySettings

    WScript.Echo "Setting the delivery delay to " _
        & defaultDeliveryDelay & " seconds (the default) ..."
    cdSettings.DeliveryDelay = defaultDeliveryDelay
    WScript.Echo "Setting the standard trickling initial size to " _
        & defaultStandardTricklingInitialSize _
        & " bytes (the default) ..."
    cdSettings.StandardTricklingInitialSize = _
        defaultStandardTricklingInitialSize
    WScript.Echo "Setting the standard trickling size to " _
        & defaultStandardTricklingSize & " bytes (the default) ..."
    cdSettings.StandardTricklingSize = _
        defaultStandardTricklingSize
    WScript.Echo "Setting the standard trickling interval to " _
        & defaultStandardTricklingInterval _
        & " seconds (the default) ..."
    cdSettings.StandardTricklingInterval = _
        defaultStandardTricklingInterval
    WScript.Echo "Setting the fast trickling mode to " _
        & defaultFastTricklingMode & " (the default) ..."
    cdSettings.FastTricklingMode = _
        defaultFastTricklingMode

    WScript.Echo  "Saving ..."
    cdSettings.Save
    WScript.Echo "Done!"
    WScript.Quit
End Sub

Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  " & WScript.ScriptName & " [/d] [/dd:value] " _
        & "[/sis:value] [/ss:value] [/ti:value] [/ftm:value] " _
        & "[/h | /?]" & VbCrLf _
        & "" & VbCrLf _
        & "    /d   - Restore the default values" & VbCrLf _
        & "    /dd  - Set delivery delay" & VbCrLf _
        & "    /sis - Set standard trickling initial size" & VbCrLf _
        & "    /ss  - Set standard trickling size" & VbCrLf _ 
        & "    /ti  - Set standard trickling interval" & VbCrLf _ 
        & "    /ftm - Set fast trickling mode" & VbCrLf _ 
        & "    value - New property value" & VbCrLf _
        & "    /h /? - Display this help."
    WScript.Quit
End Sub