Monitoring Event Sink # 8 - Register a store event sink using Regevent.vbs on Exchange
Step-by-step guide on how to register store event sinks
Per KB, Before you use regevent.vbs to register the event sink VB script, you need to register a new COM+ application on the Exchange server to properly execute script-based store events. Please follow the steps below:
1. | To start the Component Services console, click Start, select Programs, Administrative Tools, and Component Services. | ||||
2. | In the Component Services snap-in, expand the list in the following order: Component Services, Computers, and My Computer. | ||||
3. | Right-click COM+ Applications in the left pane, and select New and Application. | ||||
4. | Click Next and then choose the "Create An Empty Application" button. | ||||
5. | Enter ScriptEventSink as the name for the new application. | ||||
6. | Confirm that the Server Application radio button is selected and click Next. | ||||
7. | Click Next and click Finish. | ||||
8. | Select a user that will have owner permissions for the application you are creating, or choose the current user by selecting "Interactive User - The Current Logged On User" radio button. Note If you choose Interactive User, make sure the account that you are currently logged on with has one of the following permissions:
|
||||
9. | Open the newly created COM+ Application you just created, right-click on the Components subfolder, and choose New and, then, select Component. | ||||
10. | Click Next, then choose Install New Component(s). | ||||
11. | Browse the file system and select \Exchsrvr\Bin\exodbesh.dll. Click Next and Finish. |
After registering the new COM+ application, you need to write the event sink VB script file. Here is a sample event sink that does nothing but log its' existence:
<SCRIPT LANGUAGE="VBScript"><br>Option Explicit<br>Public Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags)<br> LogFile "ExStoreEvents_OnSave"<br>End Sub<br>public Sub ExStoreEvents_OnDelete(pEventInfo, bstrURLItem, lFlags)<br> LogFile "ExStoreEvents_OnDelete"<br>End Sub<br>Public Sub ExStoreEvents_OnSyncSave(pEventInfo, bstrURLItem, lFlags)<br> LogFile "ExStoreEvents_OnSyncSave"<br>End Sub<br>Public Sub ExStoreEvents_OnSyncDelete(pEventInfo, bstrURLItem, lFlags)<br> LogFile "ExStoreEvents_OnSyncDelete"<br>End Sub<br>public Sub LogFile(MyString)<br> Dim fso<br> Dim txtfile<br> Set fso = CreateObject("Scripting.FileSystemObject")<br> Set txtfile = fso.OpenTextFile("c:\LogFile.log", 8, True)<br> txtfile.WriteLine (MyString)<br> txtfile.Close<br>End Sub<br></SCRIPT>
We assume that the sink is now saved in the testscript.vbs., you can now register this event sink VB script using the following steps:
1. | Click Start, select Run, and type "cmd" (without the quotation marks) to enter the command prompt. |
2. | Change the directory to \Exchsrvr\Bin and type the following 2 commands: regsvr32 exodbesh.dll regsvr32 exodbprx.dll |
3. | Copy the regevent.vbs (located in the \Program Files\Exchange SDK\SDK\Support\OLEDB\Scripts directory.) and the event sink VB script files onto the root of the C drive. |
4. | Start the command prompt, and change to the directory of C:\. Type the command to run the regevent.vbs. The following command is one example: cscript regevent.vbs add "onsave;ondelete" ExOleDB.ScriptEventSink.1 "file://./backofficestorage/contoso.com/MBX/smith/inbox/testsink" -m deep -file "c:\testscript.vbs" Note:
|