Posted Outlook, Software - Microsoft Programs on Tuesday, June 28th, 2005.
For home users or corporate users without any spam filtering at the server-level, the Microsoft Junk Email filter for Outlook 2003 does a remarkable job of stopping spam email without catching any ham (valid) email. Even though it rarely catches more than 60% off incoming spam, the previous factor plus its low-maintenance filtering that doesn’t ever require training or retraining and never “decides” to label everything as spam makes it worthwhile to keep turned on.
The two big downfalls with this client-side filter are: It needs to be manually updated, since Microsoft hasn’t added non-security Office Updates to WindowsUpdate; the major search engines don’t update frequently enough to help in finding Outlook junk email filter updates until they’re two months old…
Anyway, there’s a new update for June 2005.
You can leave a response, or trackback from your own site.
Posted Windows Scripting, Exchange Server on Thursday, June 23rd, 2005.
Following a new install of Exchange and the Exchange SDK I discovered that the newest Exchange SDK doesn’t include several SMTP event sink scripts that were in previous versions. In particular, the “smtpreg.vbs” script is a configuration script used to register both VBScript (VBS) and JScript event sinks in Exchange. Using smtpreg.vbs the Exchange binding and error-checking code can be reused and event sink scripts can be shortened considerably. A quick search found a copy of the smptreg.vbs event sink management script I needed, except there are some irritating errors in the script as it is posted on the Microsoft link above. Namely, four separate times “Err.Number <> 0″ is used in the script, instead of the correct “Err.Number <> 0″. (A full corrected version of Microsoft’s script, yes their copyright and no credit or complaints to me please, is below.)
For those not familiar with SMTP event sinks for Exchange, Microsoft’s own detailed description of SMTP transport events and sinks is a good technical starting point. The non-technical starting point is: An SMTP transport event occurs whenever something passes into or out of the server via the network, and event sinks cause the server to pause processing of matching transport events until the event sink does its task and hands the event back to the server.
Acting on messages during the Exchange server processing cycle is a convenient way to modify messages, flag them based on content (viruses or intellectual property), or even filter them away from Exchange (in the case of spam). We use our own event sinks to add a disclaimer to every message that our firms sends (see Microsoft KB #317680) and strips read requests from incoming messages (see Vamsoft article). Prior to support for DNS blacklisting in Exchange 2003, we even used a shareware event sink to blacklist spam (see ORFilter by Martijn Jongen) until Exchange 2003 added blacklist support natively.
‘THIS CODE AND INFORMATION IS PROVIDED “AS IS” WITHOUT
‘WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
‘INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
‘OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
‘PURPOSE‘——————————————————————————
‘FILE DESCRIPTION: Script for managing SMTP Protocol and Transport Event Sink bindings.
‘
‘File Name: smtpreg.vbs
‘
‘
‘ Copyright (c) Microsoft Corporation 1993-1999. All rights reserved.
‘——————————————————————————
Option Explicit‘ The SMTP Source Type
Const GUID_SMTPSourceType = “{fb65c4dc-e468-11d1-aa67-00c04fa345f6}”
‘ The base Source GUID for SMTP Service Event Sources
Const GUID_SmtpSvcSourceBase = “{1b3c0666-e470-11d1-aa67-00c04fa345f6}”‘ the Event type GUIDs (COM Categories) for SMTP Service Events
‘ Protocol Events
Const catidSmtpOnInboundCommand = “{F6628C8D-0D5E-11d2-AA68-00C04FA35B82}”
Const catidSmtpOnServerResponse = “{F6628C8E-0D5E-11d2-AA68-00C04FA35B82}”
Const catidSmtpOnSessionStart = “{F6628C8F-0D5E-11d2-AA68-00C04FA35B82}”
Const catidSmtpOnMessageStart = “{F6628C90-0D5E-11d2-AA68-00C04FA35B82}”
Const catidSmtpOnPerRecipient = “{F6628C91-0D5E-11d2-AA68-00C04FA35B82}”
Const catidSmtpOnBeforeData = “{F6628C92-0D5E-11d2-AA68-00C04FA35B82}”
Const catidSmtpOnSessionEnd = “{F6628C93-0D5E-11d2-AA68-00C04FA35B82}”‘ Transport Events
Const catidSmtpStoreDriver = “{59175850-e533-11d1-aa67-00c04fa345f6}”
Const catidSmtpOnArrival = “{FF3CAA23-00B9-11d2-9DFB-00C04FA322BA}”
Const catidSmtpOnTransportSubmission = “{FF3CAA23-00B9-11d2-9DFB-00C04FA322BA}”
Const catidSmtpOnPreCategorize = “{A3ACFB0D-83FF-11d2-9E14-00C04FA322BA}”
Const catidSmtpOnCategorize = “{960252A3-0A3A-11d2-9E00-00C04FA322BA}”
Const catidSmtpOnPostCategorize = “{76719654-05A6-11d2-9E00-00C04FA322BA}”
Const catidSmtpOnTransportRouter = “{283430C9-1850-11d2-9E03-00C04FA322BA}”
Const catidSmtpMsgTrackLog = “{c6df52aa-7db0-11d2-94f4-00c04f79f1d6}”
Const catidSmtpDnsResolver = “{bd0b4366-8e03-11d2-94f6-00c04f79f1d6}”
Const catidSmtpMaxMsgSize = “{ebf159de-a67e-11d2-94f7-00c04f79f1d6}”‘ Create the GLOBAL SEO Objects used to manage the bindings.
‘ The SEO oEventManager object.
‘ This object is used to manage the event bindings database.
Dim oEventManager
Set oEventManager = CreateObject(”Event.Manager”)‘ The SEO COM Category Manager
‘ This object is used to add Implements Category keys for registered sinks.
Dim oComCatMan
Set oComCatMan = CreateObject(”Event.ComCat”)‘ SEO Utilities
‘ This object is used to generate the necessary Source GUID for a particular
‘ SMTP Service Virtual Service.
Dim oSEOUtil
Set oSEOUtil = CreateObject(”Event.Util”)‘ ** DisplayUsage **
‘ display usage information for this script
‘
public sub DisplayUsage
WScript.echo “usage: cscript smtpreg.vbs”
WScript.echo ” Commands:”
WScript.echo ” /add”
WScript.echo ” /remove”
WScript.echo ” /setprop”
WScript.echo ””
WScript.echo ” /delprop”
WScript.echo ” /enable”
WScript.echo ” /disable”
WScript.echo ” /enum”
WScript.echo ” Arguments:”
WScript.echo ”The SMTP virtual service instance”
WScript.echo ”The event name. Can be one of the following:”
WScript.echo
WScript.echo ” Transport Events:”
WScript.echo ” StoreDriver”
WScript.echo ” OnArrival (OnTransportSubmission)”
WScript.echo ” OnTransportSubmission”
WScript.echo ” OnPreCategorize”
WScript.echo ” OnCategorize”
WScript.echo ” OnPostCategorize”
WScript.Echo ” OnTransportRouter”
WScript.echo ” MsgTrackLog”
WScript.echo ” DnsResolver ”
WScript.echo ” MaxMsgSize”
WScript.echo ” Protocol Events:”
WScript.echo ” OnInboundCommand”
WScript.echo ” OnServerResponse”
WScript.echo ” OnSessionStart”
WScript.echo ” OnMessageStart”
WScript.echo ” OnPerRecipient”
WScript.echo ” OnBeforeData”
WScript.echo ” OnSessionEnd”
WScript.echo
WScript.echo ”The display name of the event to edit”
WScript.echo ”The sink Programmatic identifier”
WScript.echo ”The protocol rule to use for the event (ehlo=*,mail from=*, etc)”
WScript.echo ”The event binding GUID in registry string format: {GUID}”
WScript.echo ”The “”Source”" or “”Sink”" property bag”
WScript.echo ”The name of the property to edit”
WScript.echo ”The value to assign to the property”
end sub‘
‘ register a new sink with event manager
‘
‘ iInstance - The SMTP virtual service instance for which to register the binding.
‘ szEventName - Must be “OnArrival”
‘ szDisplayName - The display name for this new sink
‘ szProgID - The ProgId of the event sink COM Class.
‘ szRule - The protocol firing rule for the event sink.
‘ szBindingGUID - Optional. The Binding GUID to use for the binding.
‘
public sub RegisterSink(iInstance, szEventName, szDisplayName, szBindingGUID, szProgID, szRule, szPrioVal)Dim oBindings
Dim oBinding
Dim PrioVal
Dim catidEventTypeSet oBindings = GetBindings(iInstance, szEventName)
catidEventType = GetEventTypeCatID(szEventName)‘ Attempt to add the “ImplementsCategory” key for Sink using ProgID
‘ If the sink is not registered on this machine, this will fail.
‘ If this category is not registered, this method will fail.On Error Resume Next
Dim fRegCompleteOrErr
fRegCompleteOrErr = False
Do Until fRegCompleteOrErr
oComCatMan.RegisterClassImplementsCategory szProgID, catidEventType
If Err.Number <> 0 Then
Dim oldErrorNum
Dim oldErrDesc
oldErrorNum = Err.Number
oldErrDesc = Err.Description
‘ verify the COM category exists:
Err.Clear
Dim szCOMCatDesc
szCOMCatDesc = “”
szCOMCatDesc = oComCatMan.GetCategoryDescription(catidEventType,0)
if Err.Number <> 0 Then
WScript.Echo “COM Category (EventType) is not registered…”
‘ Attempt to run SMTPSEOSetup
Call ResetSMTPCatIDs()
Else
Wscript.Echo “** Registration Failed **”
Wscript.Echo ” Err.Number (HRESULT) = 0x” & Hex(oldErrorNum)
WScript.Echo ” Err.Description = ” & oldErrDesc
WScript.Echo ” ProgID = ” & szProgID
WSCript.Echo ” COM Category = ” & catidEventType
WSCript.Echo ” Corresponding Event = ” & szEventName
WScript.Echo “** Have you registered your sink COM class on this machine?”
WScript.Quit
End If
Else
fRegCompleteOrErr = True
End If
Loop‘ Sink is registered…resume registration
‘ Generate a GUID for the binding if the caller did not specify one
If szBindingGUID = “” Then
szBindingGUID = oSEOUtil.GetNewGUID
End IfSet oBinding = oBindings.Add(szBindingGUID)
‘ set the binding properties
oBinding.DisplayName = szDisplayName
oBinding.SinkClass = szProgID
‘ register a rule with the binding
oBinding.SourceProperties.Add “Rule”, szRule
‘ register a priority with the binding‘ Assign the default priority if not specified
If szPrioVal = “” Then
szPrioVal = 24575 ‘ the default
WScript.Echo “Assigning priority (” & szPrioVal & ” in 32767)”
End If
oBinding.SourceProperties.Add “Priority”, CInt(szPrioVal)‘ save the binding
oBinding.Save
If Err.Number <> 0 Then
WScript.Echo “Failed to save the binding ” & GUID_Binding
WScript.Echo Err.Number
WScript.Echo Err.Description
WScript.Quit
End IfWScript.Echo “** SUCCESS **”
WScript.Echo “Registered Binding:”
Wscript.ECho ” Event Name :” & oComCatMan.GetCategoryDescription(catidEventType,0)
WScript.Echo ” Display Name:” & szDisplayName
WScript.Echo ” Binding GUID:” & szBindingGUID
WScript.Echo ” ProgID :” & szProgID
WScript.Echo ” Rule :” & szRule
WScript.Echo ” Priority :” & szPrioVal & ” (0 - 32767, default: 24575)”
WScript.Echo ” ComCatID :” & catidEventType
end sub‘ ** GetEventTypeCatID **
‘ in: szEventName
‘ returns: COM Category ID for the Event (as a string)Function GetEventTypeCatID(szEventName)
select case LCase(szEventName)
case “storedriver”
GetEventTypeCatID = catidSmtpStoreDriver
case “onarrival”
GetEventTypeCatID = catidSmtpOnArrival
case “ontransportsubmission”
GetEventTypeCatID = catidSmtpOnTransportSubmission
case “onprecategorize”
GetEventTypeCatID = catidSmtpOnPreCategorize
case “oncategorize”
GetEventTypeCatID = catidSmtpOnCategorize
case “onpostcategorize”
GetEventTypeCatID = catidSmtpOnPostCategorize
case “ontransportrouter”
GetEventTypeCatID = catidSmtpOnTransportRouter
case “msgtracklog”
GetEventTypeCatID = catidSmtpMsgTrackLog
case “dnsresolver”
GetEventTypeCatID = catidSmtpDnsResolver
case “maxmsgsize”
GetEventTypeCatID = catidSmtpMaxMsgSize
case “oninboundcommand”
GetEventTypeCatID = catidSmtpOnInBoundCommand
case “onserverresponse”
GetEventTypeCatID = catidSmtpOnServerResponse
case “onsessionstart”
GetEventTypeCatID = catidSmtpOnSessionStart
case “onmessagestart”
GetEventTypeCatID = catidSmtpOnMessageStart
case “onperrecipient”
GetEventTypeCatID = catidSmtpOnPerRecipient
case “onbeforedata”
GetEventTypeCatID = catidSmtpOnBeforeData
case “onsessionend”
GetEventTypeCatID = catidSmtpOnSessionEnd
case else
WScript.Echo “Unrecognized Event Name: ” & szEventName
‘ This is fatal…quit!
WScript.Quit(-1)
end select
End Function‘
‘ ** UnregisterSink **
‘ Unregister a previously registered sink
‘
‘ iInstance - the SMTP Virtual Service Instance
‘ szEventName - The Event name
‘ szDisplayName - The display name of the event to remove
‘ szBindingGUID - Optional. The Binding GUID to use.public sub UnregisterSink(iInstance, szEventName, szDisplayName, szBindingGUID)
Dim oBindings
dim catidEventTypeSet oBindings = GetBindings(iInstance,szEventName)
catidEventType = GetEventTypeCatID(szEventName)‘ If the Binding GUID was given, use it to remove the binding
‘ otherwise, get it using the display nameIf szBindingGUID = “” Then
szBindingGUID = GetBindingGUIDFromDisplayName(szDisplayName,oBindings)
End IfoBindings.Remove szBindingGUID
WScript.Echo “** SUCCESS **”
WScript.Echo “Removed Binding:”
Wscript.ECho ” Event Name :” & oComCatMan.GetCategoryDescription(catidEventType,0)
WScript.Echo ” Display Name:” & szDisplayName
WScript.Echo ” Binding GUID:” & szBindingGUID
WScript.Echo ” ComCatID :” & catidEventType
end sub‘ ****************
‘ * EditProperty *
‘ ****************
‘ add or remove a property from the source or sink propertybag for an event binding
‘
‘ iInstance - The SMTP instance to edit
‘ szEvent - The event name (OnArrival, OnMessageSubmission, etc)
‘ szDisplayName - The display name of the event
‘ szBindingGUID - Optional. The GUID for the binding. Display name is used if not supplied
‘ szPropertyBag - The property bag to edit (”source” or “sink”)
‘ szOperation - “add” or “remove”
‘ szPropertyName - The name to edit in the property bag
‘ szPropertyValue - The value to assign to the name (ignored for remove)
‘
public sub EditProperty(iInstance, szEventName, szDisplayName, szBindingGUID, szPropertyBag, szOperation, szPropertyName, szPropertyValue)
Dim oBinding
Dim oPropertyBagSet oBinding = GetBinding(iInstance, szEventName, szDisplayName, szBindingGUID)
select case LCase(szPropertyBag)
case “source”
set oPropertyBag = oBinding.SourceProperties
case “sink”
set oPropertyBag = oBinding.SinkProperties
case else
WScript.echo “invalid propertybag: ” & szPropertyBag
exit sub
end select‘ figure out what operation we want to perform
select case LCase(szOperation)
case “remove”
‘ they want to remove szPropertyName from the
‘ property bag
oPropertyBag.Remove szPropertyName
WScript.echo “removed property ” & szPropertyName
case “add”
‘ add szPropertyName to the property bag and
‘ set its value to szValue. if this value
‘ already exists then this will change the value
‘ it to szValue.
oPropertyBag.Add szPropertyName, szPropertyValue
WScript.echo “set property ” & szPropertyName & ” to ” & szPropertyValue
case else
WScript.echo “invalid operation: ” & szOperation
exit sub
end select
‘ save the binding
oBinding.Save
end sub‘ ******************
‘ * SetSinkEnabled *
‘ ******************
‘ Enable/disable a registered sink
‘
‘ iInstance - The instance to work against
‘ szEvent - The event name
‘ szDisplayName - The display name for this sink
‘ szBindingGUID - The Binding GUID (optional)
‘
public sub SetSinkEnabled(iInstance, szEvent, szDisplayName, szBindingGUID, szEnable)
Dim oBinding
Set oBinding = GetBinding(iInstance, szEvent, szDisplayName, szBindingGUID)
Select Case(szEnable)
case “True”
oBinding.Enabled = True
oBinding.Save
wscript.echo “Success: Sink Binding Enabled”
case “False”
oBinding.Enabled = False
oBinding.Save
wscript.echo “Success: Sink Binding Disabled”
case else
Wscript.Echo “Error in SetSinkEnabled Routine: Invalid option.”
Wscript.Quit
End Select
end sub‘ ***********************
‘ * GetBindings Function *
‘ ***********************
‘ Returns a reference to the SEO binding object for a particular binding
‘
‘ iInstance - The SMTP Virtual Service Instance (> 0)
‘ szEventName - The Name of the Event (OnArrival, etc)Function GetBindings(iInstance, szEventName)
Dim oSourceType
Dim catidEventType
Dim oSource
Dim GUID_SMTPInstanceSourcecatidEventType = GetEventTypeCatID(CStr(szEventName))
‘ Make sure iInstance is not less than 1.
If iInstance < 1 Then
WScript.Echo "Invalid SMTP service instance: " & CStr(iInstance)
WScript.Quit
End If' Generate Source GUID using SMTP source base GUID and the instance number.
' Do this using the SEO Util object's GetIndexedGUID method.
GUID_SMTPInstanceSource = oSEOUtil.GetIndexedGUID(GUID_SmtpSvcSourceBase,iInstance)' Get the binding manager for this source
Set oSourceType = oEventManager.SourceTypes(GUID_SMTPSourceType)
Set oSource = oSourceType.Sources(GUID_SMTPInstanceSource)If typename(oSource) = "Nothing" Then
WScript.Echo "SMTP Virtual Service # " & iInstance & " Source not present...exiting."
WScript.Quit(-1)
End IfSet GetBindings = oSource.GetBindingManager.Bindings(catidEventType)
End Function
' ***********************
' * GetBinding Function *
' ***********************
' Returns a reference to the SEO binding object for a particular binding
'
' iInstance - The SMTP Virtual Service Instance (> 0)
‘ szEventName - The Name of the Event (OnArrival, etc)
‘ szDisplayName - The Display Name for the binding. Used to retrieve binding GUID
‘ if is it not supplied
‘ szBindingGUID - The GUID for the binding. If not “”, this GUID is used.
‘
Function GetBinding(iInstance, szEventName, szDisplayName,szBindingGUID)
Dim oSourceType
Dim catidEventType
Dim oSource
Dim oBindings
Dim oBinding
Dim GUID_SMTPInstanceSourcecatidEventType = GetEventTypeCatID(CStr(szEventName))
‘ Make sure iInstance is not less than 1.
If iInstance < 1 Then
WScript.Echo "Invalid SMTP service instance: " & CStr(iInstance)
WScript.Quit
End If' Generate Source GUID using SMTP source base GUID and the instance number.
' Do this using the SEO Util object's GetIndexedGUID method.
GUID_SMTPInstanceSource = oSEOUtil.GetIndexedGUID(GUID_SmtpSvcSourceBase,iInstance)' Get the binding manager for this source
Set oSourceType = oEventManager.SourceTypes(GUID_SMTPSourceType)
Set oSource = oSourceType.Sources(GUID_SMTPInstanceSource)If typename(oSource) = "Nothing" Then
WScript.Echo "SMTP Virtual Service # " & iInstance & " Source not present...exiting."
WScript.Quit(-1)
End IfSet oBindings = oSource.GetBindingManager.Bindings(catidEventType)
If szBindingGUID = "" Then
szBindingGUID = GetBindingGUIDFromDisplayName(SzDisplayName, oBindings)
End IfSet oBinding = oBindings(szBindingGUID)
If TypeName(oBinding) = "Nothing" Then
WScript.Echo "** ERROR **"
WScript.Echo "No binding present for GUID " & szBindingGUID
WScript.Quit
Else
Set GetBinding = oBinding
End IfEnd Function
'
' this helper function takes an IEventSource object and a event category
' and dumps all of the bindings for this category under the source
'
' Source - the IEventSource object to display the bindings for
' GUIDComCat - the event category to display the bindings for
'
public sub DisplayBindingHelper(oSource, oEventType)
Dim Binding
Dim PropName
Dim Props' walk each of the registered bindings for this component category
dim strSpaces
strSpaces = " "
for each Binding in oSource.GetBindingManager.Bindings(oEventType.id)
wscript.echo " ---------"
wscript.echo " | Binding |"
Wscript.Echo " ---------"
WScript.Echo strSpaces & " Event: " & oEventType.DisplayName
WScript.echo strSpaces & " ID: " & Binding.ID
WScript.echo strSpaces & " Name: " & Binding.DisplayName
WScript.echo strSpaces & " SinkClass: " & Binding.SinkClass
WScript.echo strSpaces & " Enabled: " & Binding.EnabledSet Props = Binding.SourceProperties
If Props.Count > 0 Then
WScript.echo strSpaces & “SourceProperties: {”
for each PropName in Props
WScript.echo strSpaces & ” ” & propname & ” = ” & Binding.SourceProperties(propname)
next
WScript.echo strSpaces & ” }”
End IfSet Props = Binding.SinkProperties
If Props.Count > 0 Then
WScript.echo strSpaces & “SinkProperties {”
for each Propname in Props
WScript.echo strSpaces & ” ” & PropName & ” = ” & Props(PropName)
next
WScript.echo strSpaces & ” }”
End If
next
end sub‘
‘ dumps all of the information in the binding database related to SMTP
‘
public sub DisplaySinks
Dim SourceType
Dim Source
Dim eventtype
On Error Resume Next
For Each SourceType in oEventManager.SourceTypes
wscript.echo ” ————-”
Wscript.Echo “| Source Type |”
Wscript.Echo ” ————-”
Wscript.echo ” Name: ” & SourceType.DisplayName
WScript.Echo ” ID: ” & SourceType.ID
for each eventtype in sourcetype.eventtypes
wscript.echo ” ————”
wscript.echo ” | Event Type |”
Wscript.Echo ” ————”
WScript.Echo ” Name: ” & eventtype.DisplayName
WSCript.Echo ” ID: ” & eventtype.ID
next
for each Source in SourceType.Sources
‘ display the source properties
wscript.echo ” ——–”
wscript.echo ” | Source |”
Wscript.Echo ” ——–”
WScript.echo ” Name: ” & Source.DisplayName
WScript.echo ” ID: ” & Source.ID
for each eventtype in sourcetype.eventtypes
call DisplayBindingHelper(Source, eventtype)
next
next
Next
end sub‘ ************************
‘ * SetDisplayNameOrGUID *
‘ ************************
‘ Examines the arguments to determine whether a GUID
‘ or a display name was passed. All GUIDs must be passed in the form
‘ “{871736C0-FD85-11D0-869A-00C04FD65616}”
‘ and display names must not start with a left-bracket “{”
‘Sub SetDisplayNameOrGUID(ByRef szArg, ByRef szDisplayName, ByRef szBindingGUID)
‘ check for left bracked used for a GUID
If (InStr(1,szArg, “{”, 1) = 1) Then
WScript.Echo “Binding GUID specified: ” & szArg
szBindingGUID = szArg
szDisplayName = “”
Else
WScript.Echo “Binding Display Name Specified: ” & szArg
szBindingGUID = “”
szDisplayName = szArg
End If
End Sub‘ *********************************
‘ * GetBindingGUIDFromDisplayName *
‘ *********************************
‘ Attempts to return the binding GUID for a binding
‘ based upon the binding display name
‘
‘ szDisplayName - [in] The display name for the binding
‘ oBindings - [in] The SEO EventBindings Object
‘
‘ Returns
‘ If successful, returns the binding GUID for the binding.
‘ The first matched display name is used. That is, if multiple bindings
‘ have the same display name, the first found is used.Function GetBindingGUIDFromDisplayName(SzDisplayName, oBindings)
Dim oBinding
for each oBinding in oBindings
if oBinding.DisplayName = szDisplayName then
GetBindingGUIDFromDisplayName = oBinding.ID
exit function
End If
nextWScript.Echo “Failed to find binding with display name:” & szDisplayName
WScript.QuitEnd Function
‘ *******************
‘ * ResetSMTPCatIDs *
‘ *******************
‘ - Registers the various COM categories for SMTP transport and protocol
‘ events.
‘ - Adds each as an event type to the SMTP Service Source Type
‘
‘
Sub ResetSMTPCatIDs()WScript.Echo “Running ResetSMTPCatIDs…one moment”
On Error Resume Next
Err.ClearDim oSourceType
Set oSourceType = oEventManager.SourceTypes(GUID_SMTPSourceType)
If TypeName(oSourceType) = “Nothing” Then
WScript.Echo “** ERROR **”
Wscript.Echo “No SMTP Source Type registered.”
WScript.Echo “Is the SMTP Service installed on this machine?”
WScript.Quit
End IfoComCatMan.RegisterCategory catidSmtpStoreDriver, “SMTP StoreDriver”, 0
oSourceType.EventTypes.Add catidSmtpStoreDriveroComCatMan.RegisterCategory catidSmtpOnTransportSubmission, “SMTP OnTransportSubmission/OnArrival”, 0
oSourceType.EventTypes.Add catidSmtpOnTransportSubmissionoComCatMan.RegisterCategory catidSmtpOnPreCategorize, “SMTP OnPreCategorize”,0
oSourceType.EventTypes.Add catidSmtpOnPreCategorizeoComCatMan.RegisterCategory catidSmtpOnCategorize, “SMTP OnCategorize”,0
oSourceType.EventTypes.Add catidSmtpOnCategorizeoComCatMan.RegisterCategory catidSmtpOnPostCategorize, “SMTP OnPostCategorize”,0
oSourceType.EventTypes.Add catidSmtpOnPostCategorizeoComCatMan.RegisterCategory catidSmtpOnTransportRouter, “SMTP OnTransportRouter”,0
oSourceType.EventTypes.Add catidSmtpOnTransportRouteroComCatMan.RegisterCategory catidSmtpMsgTrackLog, “SMTP MsgTrackLog”, 0
oSourceType.EventTypes.Add catidSmtpMsgTrackLogoComCatMan.RegisterCategory catidSmtpDnsResolver, “SMTP DnsResolver”, 0
oSourceType.EventTypes.Add catidSmtpDnsResolveroComCatMan.RegisterCategory catidSmtpMaxMsgSize, “SMTP MaxMsgSize”, 0
oSourceType.EventTypes.Add catidSmtpMaxMsgSizeoComCatMan.RegisterCategory catidSmtpOnInBoundCommand, “SMTP OnInBoundCommand”, 0
oSourceType.EventTypes.Add catidSmtpOnInBoundCommandoComCatMan.RegisterCategory catidSmtpOnServerResponse, “SMTP OnServerResponse”, 0
oSourceType.EventTypes.Add catidSmtpOnServerResponseoComCatMan.RegisterCategory catidSmtpOnSessionStart, “SMTP OnSessionStart”, 0
oSourceType.EventTypes.Add catidSmtpOnSessionStartoComCatMan.RegisterCategory catidSmtpOnMessageStart, “SMTP OnMessageStart”, 0
oSourceType.EventTypes.Add catidSmtpOnMessageStartoComCatMan.RegisterCategory catidSmtpOnPerRecipient, “SMTP OnPerRecipient”, 0
oSourceType.EventTypes.Add catidSmtpOnPerRecipientoComCatMan.RegisterCategory catidSmtpOnBeforeData, “SMTP OnBeforeData”, 0
oSourceType.EventTypes.Add catidSmtpOnBeforeDataoComCatMan.RegisterCategory catidSmtpOnSessionEnd, “SMTP OnSessionEnd”, 0
oSourceType.EventTypes.Add catidSmtpOnSessionEndIf Err.Number <> 0 Then
WScript.Echo “** ERROR ** ”
Wscript.Echo “Error registering COM categories”
WScript.Echo Err.Number
WScript.Echo Err.Description
Wscript.Echo “Make sure the SMTP Service is installed on the machine”
WScript.Quit
End If‘ Remove the duplicate, redundant SMTP SourceType
Const GUID_ExtraSMTPSourceType = “{4f803d90-fd85-11d0-869a-00c04fd65616}”
EVentManager.SourceTypes.Remove(GUID_ExtraSMTPSourceType)End Sub
‘ **********************
‘ * Main Routine Start *
‘ **********************Dim iInstance
Dim szEvent
Dim szDisplayName
Dim szSinkClass
Dim szRule
Dim szPrio
Dim szBindingGUID
Dim szPropertyBag
Dim szPropertyName
Dim szPropertyValue
dim bCheck
Dim ArgCount
‘
‘ this is the main body of our script. it reads the command line parameters
‘ specified and then calls the appropriate function to perform the operation
‘
if WScript.Arguments.Count = 0 then
call DisplayUsage
else
ArgCount = WScript.Arguments.Count
Select Case LCase(WScript.Arguments(0))
Case “/?”
DisplayUsage
Case “/add”
if not ArgCount = 6 and not ArgCount = 7 then
call DisplayUsage
else
iInstance = WScript.Arguments(1)
szEvent = WScript.Arguments(2)
Call SetDisplayNameOrGUID(WScript.Arguments(3), szDisplayName, szBindingGUID)
szSinkClass = WScript.Arguments(4)
szRule = WScript.Arguments(5)
If ArgCount = 7 Then
szPrio = WScript.Arguments(6)
Else
szPrio = “”
End If
call RegisterSink(iInstance, szEvent, szDisplayName, szBindingGUID, szSinkClass, szRule, szPrio)
end if
Case “/remove”
if not ArgCount = 4 then
call DisplayUsage
else
iInstance = WScript.Arguments(1)
szEvent = WScript.Arguments(2)
Call SetDisplayNameOrGUID(WScript.Arguments(3), szDisplayName, szBindingGUID)
call UnregisterSink(iInstance, szEvent, szDisplayName, szBindingGUID)
end if
Case “/setprop”
if not ArgCount = 7 then
call DisplayUsage
else
iInstance = WScript.Arguments(1)
szEvent = WScript.Arguments(2)
Call SetDisplayNameOrGUID(WScript.Arguments(3), szDisplayName, szBindingGUID)
szPropertyBag = WScript.Arguments(4)
szPropertyName = WScript.Arguments(5)
szPropertyValue = WScript.Arguments(6)
call EditProperty(iInstance, szEvent, szDisplayName, szBindingGUID, szPropertyBag, “add”, szPropertyName, szPropertyValue)
end if
Case “/delprop”
if not ArgCount = 6 then
call DisplayUsage
else
iInstance = WScript.Arguments(1)
szEvent = WScript.Arguments(2)
Call SetDisplayNameOrGUID(WScript.Arguments(3), szDisplayName, szBindingGUID)
szPropertyBag = WScript.Arguments(4)
szPropertyName = WScript.Arguments(5)
call EditProperty(iInstance, szEvent, szDisplayName, szBindingGUID, szPropertyBag, “remove”, szPropertyName, “”)
end if
Case “/enable”
if not ArgCount = 4 then
call DisplayUsage
else
iInstance = WScript.Arguments(1)
szEvent = WScript.Arguments(2)
Call SetDisplayNameOrGUID(WScript.Arguments(3), szDisplayName, szBindingGUID)
call SetSinkEnabled(iInstance, szEvent, szDisplayName, szBindingGUID, “True”)
end if
Case “/disable”
if not ArgCount = 4 then
call DisplayUsage
else
iInstance = WScript.Arguments(1)
szEvent = WScript.Arguments(2)
Call SetDisplayNameOrGUID(WScript.Arguments(3), szDisplayName, szBindingGUID)
call SetSinkEnabled(iInstance, szEvent, szDisplayName, szBindingGUID, “False”)
end if
Case “/enum”
if not ArgCount = 1 then
call DisplayUsage
else
call DisplaySinks
end if
Case “/resetcatids”
call ResetSMTPCatIDs
Case Else
call DisplayUsage
End Select
end if
You can leave a response, or trackback from your own site.
Posted Outlook, Software - Microsoft Programs on Monday, June 20th, 2005.
Outlook 2002 and 2003 attempt to auto-complete name and email addresses typed into the To:, Cc:, Bcc: and From: fields of messages. Anyone using Outlook for sometime will know this feature saves a great deal of time and almost eliminates looking up email addresses once they’ve been cached. The big problem, and the reason for this article, is that the cache isn’t validated or checked against changes in the address book.
Relying heavily on the auto-complete feature can be a problem when a contact’s email address changes or if an address with a typo is cached. Outlook doesn’t provide a way to update or validate the cached addresses. …except when addresses get flushed. With current Outlook versions an .NK2 file only holds the 1,000 most-recent email addresses.
There are two ways, that I know of, to “fix” the cache. The first method edits the file from within Outlook and the second method clears the cache completely:
Editting Specifc Names in Outlook .NK2 Cache Files:
To edit the cache, just start a new message in Outlook. In the address field start typing the name or address necessary to make Outlook show the selection list that contains the incorrect email address. Press the down arrow to select the incorrect address and then press the delete key. The address that was selected will be deleted from the .NK2 file - the correct address will be added as soon as it is used in an email.
Resetting/Clearing the Outlook Auto-Complete Cache:
The cache can easily be reset by searching for and deleting the “Outlook.NK2″, “MS Exchange Settings.NK2″ or other *.NK2 file associated with a particular Outlook user account. On Windows XP desktops these files are typically in %userprofile%\Application Data\Microsoft\Outlook. Generally the “Outlook.NK2″ file will be the correct one to delete to clear auto-complete information. If there are multiple Outlook profiles created in one Windows User Profile, then additional .NK2 files are typically named after the profile.
You can leave a response, or trackback from your own site.
Posted Windows Servers, SAN & NAS Storage, Windows 2003 Server, Windows 2000 Server on Wednesday, June 15th, 2005.
Adding disks to a new EMC AX100i at one of our offices, the fastest solution to expand the volume sizes was to upgrade them to Windows dynamic volumes and add the new disks to the volume. With no mirroring and plenty of server power, the use of the dynamic volumes was unlikely to impact performance but it would eliminate the need to transfer data off and on the EMC array. The dynamic volumes worked well at first, but turned out to be a bad idea that next time the attached servers were rebooted.
The iSCSI volumes were not attached when the servers started up and the “merge foreign disks” command needed to be run before the array could even be addressed by the server. The only way to keep the error from happening at every reboot was to remove the data, rebuild the volumes on the AX100i, and then move the data back - no time saved after all.
I expect that our use of the Microsoft iSCSI initiator had a lot to do with the problems. An iSCSI HBA would have made the volumes available earlier in the boot process and probably prevented the foreign disk status. Nonetheless, if we had wanted to spend the extra money on HBAs we probably would have bought a fibre channel array instead of iSCSI.
(A May 2005 article also mentions that loading Windows 2003 Server SP1 will result in crashes due to either Navisphere orPowerPath software.)
You can leave a response, or trackback from your own site.
Posted Windows Desktop Fixes on Sunday, June 12th, 2005.
Dear Microsoft Desktop OS Product Manager:
The Desktop Cleanup Wizard is one of the most frustrating and irritating things about Windows XP. Three years after the OS was released a steady stream of corporate users and clients unfamiliar with the feature are frustrated by fileas and icons being moved off their desks.
Sure, it’s easy enough to turn off the feature - it’s also just as easy to turn on. Fortunately turing the feature on allows users to make a choice before consigning themselves to an automated desktop. Please configure new features in an off-state, particularly those that move files and data.
Thanks,
-A Concerned SysAdmin
—
To disable the Windows XP Desktop Cleanup Wizard: It is easy to disable this after setting up a machine, but the feature is a pain to those who aren’t aware it exists.
- Open the Display Control Panel. Either open Control Panels > click “Display”, or right-click on the desktop and select “Properties”.
- Select the “Desktop” Tab > click the “Customize Desktop” button.
- Uncheck the box next to the “Run desktop cleanup wizard every 60 days…” option, near the bottom. Press OK twice.
Incidentally, if the trashcan and My Document’s folder get in the way, they can also be hidden via the “Customize Desktop” tab.
You can leave a response, or trackback from your own site.
Posted WiFi Wireless Networking on Tuesday, June 7th, 2005.
Review Summary:
Linksys manufactures several models of antennas to improve the range of 802.11b and 802.11g, also called Wireless-B and Wireless-G, network connections. The HGA7S model is a single antenna designed to replace the removable antennas on most brands of PCI-bus wireless adapters and some access points. Raw specifications suggest that wireless range should be improved about 2.6x normal by adding this antenna to the networking setup. Due to noise and signal degradation playing a large role in an office setting, the signal strength improved enough to add only 25-30% (about 1.3x normal) to the effective range of consumer grade access points. Using the separate antenna stands sold by Linksys (model AS1SMA) the antenna could be relocated away from walls and corners, making this antenna and the stand a moderately effective solution to signal cancellation. There are more effective options for improving wireless range, although none is quite as inexpensive as the Linksys High Gain antennas (currently selling for only $36.05 on Amazon.com).
Detailed Review:
The biggest advantage of this antenna over other range-increasing devices is the easy installation. The original, OEM, antenna can be unscrewed and this antenna attached even with the WiFi card or access point turned on. Waiting a minute for the card or access point to reconnect to the opposite end of the WiFi connection is required after a powered-on swap. Just make sure there is enough additional overhead space for this antenna. It is 11.5-inches long and, to be most effective, it should be vertical and not tilted (omni-directional antennas, like both this and OEM 2.2 dBi ones, are most effective when placed vertically). Indoors an omni-directional antenna should be tilted only in situations where a wall or angled surface causes signal reflection noise. Without enough overhead space the Linksys AS1SMA antenna stand can be purchased separately and used to relocate the antenna a short distance from the SMA connector on the PCI-card or access point. This additional freedom of movement proved helpful in improving the wireless signal for PCs that were placed in angled corners or inside enclosed cabinets.
The low cost of this antenna is a small advantage over other range-increasing devices. It is a quick fix for spotty wireless connections, but because adding it yielded only limited range increases in both office and home it isn’t a solution when no signal at all reaches an enclosed or distant area. In indoor situations enclosed areas may have too much signal noise for any antenna to help. Distant areas in indoor situations can be completely shielded by walls and have no signal to amplify. For such distant or enclosed areas more expensive solutions like the Belkin F5D7130 in repeater-mode or NetGear’s RangeMax Access Point are the most likely to help.
According to specifications the HGA7S antenna has a peak gain of 7 dBi. Most OEM antennas included with wireless access points and PCI-bus cards only have a peak gain of 2.2 dBi. The range of an antenna in an open field with no other interference should double about every +3 dBi. So, in an open field the HGA7S antenna adds about 4.8 dBi of gain, and +4.8 dBi/3 dBi per 2x range = 2.6x normal range. Unfortunately our tests in indoor environments resulted in about 1.2-1.5x the pre-HGA7S range.
Before purchasing the HGA7S, several things to check on existing equipment:
- Does the device to be upgraded have a removable antenna with an SMA connector?
- Is the existing device either 802.11b or 802.11g? This antenna will not work with new 802.11n or older 802.11a equipment.
- Does the existing connection fail occasionally or completely not connect? A wireless signal repeater or Wireless-N/MiMo access points are more likely to be effective in greatly increasing range.
You can leave a response, or trackback from your own site.
Posted Windows Desktop Fixes, Windows 2003 Server on Thursday, June 2nd, 2005.
The Intel 852/855, 865G, and 945G video chipsets are integrated with numerous desktop, laptop, and server motherboards. Older versions of the drivers for these chipsets, often installed at the OEM factory, may conflict with patches or other drivers on each of Windows XP Home, XP Pro, and 2003 Server. Blue-screen-of-death and memory dump errors will result from running old versions of this driver. The text of these messages includes:
- “DRIVER_IRQL_NOT_LESS_OR_EQUAL”
- Driver conflict error: “ialmnt5.sys”
- DLL communication error: “ialmdev5.dll”
The error often occurs following Windows Service Pack upgrades, Windows Update installs, and the running of new video games. After the error appears it is usually possible to boot into safe-mode (restart and press F8 at the BIOS screen to start in safe-mode) to install the newest version of the driver. Download and install newest driver version from: http://support.intel.com/support/graphics/
In the case of the 852/855 mobile graphics chipsets the driver update may need to be done twice. Laptops with docks have two copies of the Intel video driver; both the docked and undocked profiles of the laptop have copies of the driver loaded. To completely fix the laptop install the newest drivers in one mode, restart, dock or undock the laptop, reinstall the drivers in the second mode, and finally reboot the laptop again.
You can leave a response, or trackback from your own site.
