Share via


IFPCAlertActions::SetCommand method

Applies to: desktop apps only

The SetCommand method creates a new command-line action in the collection, or updates the command-line action if it already exists, and then returns a reference to it.

Syntax

HRESULT SetCommand(
  [in]   BSTR ActionName,
  [in]   BSTR Command,
  [out]  IFPCAlertAction **ppNewAction
);
FPCAlertActions.SetCommand( _
  ByVal ActionName As String, _
  ByVal Command As String, _
  ByRef ppNewAction As IFPCAlertAction _
) As FPCAlertAction

Parameters

  • ActionName [in]
    Required. String value that specifies the name of the action. This name is used to identify the action in the FPCAlertActions collection if it already exists.

  • Command [in]
    Required. String value that specifies the command line. If the command line includes a path to an executable file that contains one or more spaces, the full path, including the name of the executable file, must be enclosed in double quotation marks in addition to the set of quotation marks that enclose the string value.

  • ppNewAction [out]
    Address of an interface pointer that on return points to the IFPCAlertAction interface for the new or updated command-line action.

Return value

C++

This method can return one of the following:

  • S_OK, indicating that the operation succeeded.
  • An error code, indicating that the operation failed. In this case, the [out] parameter returned is a null object.

VB

This method returns a reference to an FPCAlertAction object if successful. Otherwise, an error is raised that can be intercepted by using an error handler.

Examples

This VBScript script creates a command-line action for the user-specified alert. Note that the hard-coded command line in this script includes a path to an executable file that contains spaces.

' Define the constant needed
const Error_FileNotFound = &H80070002
Main(WScript.Arguments)
Sub Main(args)
    If(args.Count = 1) Then
        SetAlertAction args(0)
    Else
        Usage()
    End If
End Sub
Sub SetAlertAction(alertName)
    ' Create the root object.
    Dim root  ' The FPCLib.FPC root object
    Set root = CreateObject("FPC.Root")
    ' Declare the other objects needed.
    Dim isaArray        ' An FPCArray object
    Dim alert           ' An FPCAlert object
    Dim actions         ' An FPCAlertActions collection
    Dim action          ' An FPCAlertAction object
    Dim actionName      ' A String
    Dim command         ' A String
    ' Get a reference to the local array object.
    Set isaArray = root.GetContainingArray()
    ' Get a reference to the alert specified.
    On Error Resume Next
    Set alert = isaArray.Alerts.Item(alertName)
    If Err.Number = Error_FileNotFound Then
        WScript.Echo "The alert specified could not be found."
    Else
        Err.Clear
        On Error GoTo 0
        Set actions = alert.Actions
        actionName = "Command Line"
        command = """C:\Program Files\Microsoft Forefront TMG\Myalertscript.cmd"" 1000"
        Set action = actions.SetCommand(actionName, command)
        alert.Save
    End If
End Sub
Sub Usage()
    WScript.Echo "Usage:" & VbCrLf _
        & "  CScript " & WScript.ScriptName & " Alert Command" & VbCrLf _
        & "" & VbCrLf _
        & "    Alert - Name of the alert" 
    WScript.Quit
End Sub

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 (64-bit only)

Version

Forefront Threat Management Gateway (TMG) 2010

IDL

Msfpccom.idl

DLL

Msfpccom.dll

See also

FPCAlertActions

 

 

Build date: 7/12/2010