Redigera

Dela via


ActiveScriptEventConsumer class

The ActiveScriptEventConsumer class runs a predefined script in an arbitrary scripting language when an event is delivered to it. This class is one of the standard event consumers that WMI provides. For more information, see Monitoring and Responding to Events with Standard Consumers.

Mofcomp -n:root\<namespace> scrcons.mof

You can configure the performance of all instances of ActiveScriptEventConsumer on a system by setting the values of either the Timeout or MaximumScripts property in the single instance of ScriptingStandardConsumerSetting.

Syntax

[AMENDMENT]
class ActiveScriptEventConsumer : __EventConsumer
{
  uint8  CreatorSID[] = {1,1,0,0,0,0,0,5,18,0,0,0};
  uint32 KillTimeout = 0;
  string MachineName;
  uint32 MaximumQueueSize;
  string Name;
  string ScriptingEngine;
  string ScriptFileName;
  string ScriptText;
};

Members

The ActiveScriptEventConsumer class has these types of members:

Properties

The ActiveScriptEventConsumer class has these properties.

CreatorSID

Data type: uint8 array

Access type: Read-only

Array that represents the security identifier (SID), which uniquely identifies the creator of the Active Script Event consumer. This property is inherited from __EventConsumer.

KillTimeout

Data type: uint32

Access type: Read-only

Number, in seconds, that the script is allowed to run. If 0 (zero), which is the default, the script is not terminated.

MachineName

Data type: string

Access type: Read-only

Name of the computer to which WMI sends events. By convention of Microsoft standard consumers, the script consumer cannot be run remotely. Third-party consumers can also use this property. This property is inherited from __EventConsumer.

MaximumQueueSize

Data type: uint32

Access type: Read-only

Maximum queue, in bytes, for the Active Script Event consumer. This property is inherited from __EventConsumer.

Name

Data type: string

Access type: Read/write

Qualifiers: Key

Unique identifier for the event consumer. If you rename the consumer, the result is two equal consumers that have different names.

ScriptFileName

Data type: string

Access type: Read-only

Name of the file from which the script text is read, intended as an alternative to specifying the text of the script in the ScriptText property. This property must be NULL if the ScriptText property is not NULL.

Note

When you specify the ScriptFileName, it is important to secure the executable that you are launching. If the executable is not in a secure location or secured with a strong access control list (ACL), anyone can replace the executable with a different one. For more information about ACLs, see Creating a Security Descriptor (SD) for a New Object in C++.

ScriptingEngine

Data type: string

Access type: Read-only

Name of the scripting engine to use, for example, "VBScript". This property cannot be NULL.

ScriptText

Data type: string

Access type: Read-only

Text of the script that is expressed in a language known to the scripting engine. This property must be NULL if the ScriptFileName property is not NULL.

Remarks

This class is derived from the __EventConsumer abstract class. It is located in the root\subscription namespace.

When the text of a script is specified in the event consumer instance, the script has access to the event instance in the script environment variable TargetEvent.

The scripts run in the LocalSystem security context. As a security measure, only a local system administrator or a domain administrator can configure the scripting consumer. Access rights are not checked until run time. After the consumer is configured, any user can trigger the event that causes the script to .

Failure to load the scripting engine or parse and validate the script is considered a failure. Error return codes from the script and terminating the script by using a time-out are also considered failures.

Either ScriptText or ScriptFileName must be not NULL. If both properties are NULL or not NULL, an error is generated.

When WMI is run as a service, scripts run by ActiveScriptEventConsumer do not generate screen output. Scripts that use MsgBox do run, but they do not display information on the screen. Running the WMI service as an executable file is not supported, but WMI allows scripts that use the MsgBox function to display output or accept user input. None of the methods provided by the WScript object can be used because ActiveScriptEventConsumer does not use Windows Script Host (WSH).

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Namespace
Root\subscription
MOF
Scrcons.mof
DLL
Scrcons.exe

See also

Standard Consumer Classes

Running a Script Based on an Event

Receiving Events At All Times

Creating a Logical Consumer

__EventConsumer

ScriptingStandardConsumerSetting