SetCommand Method of the IFPCAlertActions Interface

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.

[C++]

Syntax

HRESULT SetCommand(
  [in]   BSTR ActionName,
  [in]   BSTR Command,
  [out]  IFPCAlertAction** ppNewAction
);

Parameters

ActionName

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

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

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

Return Value

This method can return one of the following:

[Visual Basic]

Syntax

Function SetCommand( _
  ByVal ActionName As String, _
  ByVal Command As String _
) As FPCAlertAction

Parameters

ActionName

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

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.

Return Value

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.

Example Code

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

Client Requires Windows Vista or Windows XP.
Server Requires Windows Server 2008.
Version Requires Forefront Threat Management Gateway (TMG).
IDL

Declared in Msfpccom.idl.

DLL

Requires Msfpccom.dll.

See Also

FPCAlertActions


Send comments about this topic to Microsoft

Build date: 11/30/2009

© 2008 Microsoft Corporation. All rights reserved.