Поделиться через


WMS Active Script Event Handler Plug-in Properties

Note

   This plug-in is available only on Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; and Windows Server 2008. For administration information about this plug-in, see Windows Media Services Help.

The WMS Active Script Event Handler plug-in responds to event notices raised from the server by calling the appropriate callback in a script file that you create. The following sections provide examples of valid callbacks your script can contain:

If you have a script debugger installed on your computer, you can debug the callback procedures in your script. If you do not have one installed, you can download the Microsoft Script Debugger from the Windows Script page on the Microsoft Web site. However, the Microsoft Script Debugger does not work in the Network Service account that Windows Media Services runs in. Therefore, to use the Microsoft Script Debugger, you must configure Windows Media Services to operate in the System account. To configure Windows Media Services to run in the System account, perform the following steps:

  1. On the Start menu, click Settings, and then click Control Panel.

  2. Double click Administrative Tools.

  3. Double click Services.

  4. Double click Windows Media Services.

  5. On the Windows Media Services Properties (Local Computer) dialog box, click the Log On tab.

  6. Select Local System Account.

  7. Click OK.

Important noteImportant Note:

   Remember to return Windows Media Services to the Network Service account when debugging is complete so that adequate security can be maintained.

You can use the IWMSActiveScriptAdmin interface to configure the following properties programmatically.

Property

Description

EnableDebugging

Specifies and retrieves a Boolean value that indicates whether the Microsoft Script Debugger can be used to debug the script specified by the FileName property.

ErrorCharacterPosition

Retrieves the character position of the last error that occurred in the script, if script debugging is enabled.

ErrorLineNumber

Retrieves the line number of the last error that occurred in the script, if script debugging is enabled.

ErrorText

Retrieves the text of the last error that occurred in the script, if script debugging is enabled.

FileName

Specifies and retrieves the path to the script file.

The following examples illustrate how to configure these properties.

Visual Basic .NET Example

Imports Microsoft.WindowsMediaServices.Interop 
Imports System.Runtime.InteropServices

Private Sub SetActiveScriptPluginProps()

' Declare variables.
Dim Server As WMSServer
Dim Plugin As IWMSPlugin
Dim ActiveScriptAdmin As IWMSActiveScriptAdmin

Try
    ' Create a new WMSServer object.
    Server = New WMSServer()

    ' Retrieve the IWMSPlugin object for the 
    ' WMS Active Script Event Handler plug-in.
    Plugin = Server.EventHandlers("WMS Active Script Event Handler")

    ' Retrieve the administrative interface for the plug-in.
    ActiveScriptAdmin = Plugin.CustomInterface()

    ' Specify the name of the script file to use.
    ActiveScriptAdmin.FileName = "C:\Scripts\script.vbs"

    ' Specify a Boolean value indicating whether script
    ' debugging is enabled.
    ActiveScriptAdmin.EnableDebugging = True
Catch excCom As COMException
    ' TODO: Handle COM exceptions.
Catch exc As Exception
    ' TODO: Handle exceptions here.
Finally
    ' TODO: Perform clean-up here.
End Try
End Sub

C# Example

using Microsoft.WindowsMediaServices.Interop; 
using System.Runtime.InteropServices;

// Declare variables.
WMSServer Server;
IWMSPlugin Plugin;
IWMSActiveScriptAdmin ActiveScriptAdmin;

try
{
    // Create a new WMSServer object.
    Server = new WMSServerClass();

    // Retrieve the IWMSPlugin object for the 
    // WMS Active Script Event Handler plug-in.
    Plugin = Server.EventHandlers["WMS Active Script Event Handler"];

    // Retrieve the administrative interface for the plug-in.
    ActiveScriptAdmin = (IWMSActiveScriptAdmin)Plugin.CustomInterface;

    // Specify the name of the script file to use.
    ActiveScriptAdmin.FileName = "C:\\Scripts\\script.vbs";

    // Specify a Boolean value indicating whether script
    // debugging is enabled.
    ActiveScriptAdmin.EnableDebugging = true;
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception exc)
{
    // Handle exceptions here.
}
finally
{
    // TODO: Perform clean-up here.
}

C++ Example

#include <windows.h>
#include <atlbase.h>

// To access system plug-in interfaces, the
// type library must be imported as shown.
#import "WMSServerTypeLib.dll" no_namespace named_guids \
                               raw_interfaces_only

// Declare variables and interface pointers.
IWMSServer*              pServer = NULL;
IWMSPlugins*             pPlugins = NULL;
IWMSPlugin*              pPlugin = NULL;
IDispatch*               pDispatch = NULL;
IWMSActiveScriptAdmin*   pActiveScriptAdmin = NULL;
CComVariant              varIndex;
CComBSTR                 bstrScriptFile;
HRESULT                  hr = S_OK;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to an IWMSPlugins interface
// containing the collection of event handler plug-ins.
hr = pServer->get_EventHandlers(&pPlugins);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSPlugin interface for the
// WWMS Active Script Event Handler plug-in.
varIndex = "WMS Active Script Event Handler";
hr = pPlugins->get_Item(varIndex, &pPlugin);
if (FAILED(hr)) goto EXIT;

// Retrieve an IDispatch pointer to the administration
// interface for the plug-in.
hr = pPlugin->get_CustomInterface(&pDispatch);
if (FAILED(hr)) goto EXIT;

// Call QueryInterface() to retrieve a pointer to the
// IWMSCPPluginAdmin interface.
hr = pDispatch->QueryInterface(IID_IWMSActiveScriptAdmin, (void**)&pActiveScriptAdmin);
if (FAILED(hr)) goto EXIT;

// Set the current script file name.
bstrScriptFile = "C:\\Scripts\\script.vbs";
hr = pActiveScriptAdmin->put_FileName(bstrScriptFile);
if (FAILED(hr)) goto EXIT;

// Set a Boolean value indicating whether script
// debugging is enabled.
hr = pActiveScriptAdmin->put_EnableDebugging(VARIANT_TRUE);
if (FAILED(hr)) goto EXIT;

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

See Also

Reference

IWMSActiveScriptAdmin Interface

IWMSActiveScriptAdmin Object (C#)

IWMSActiveScriptAdmin Object (Visual Basic .NET)

Concepts

Programming System Plug-in Properties