UserPreferences

SpamBayesStartStop


Note: This wiki is now frozen; you can no longer edit it, and no interactive features work.

1. SpamBayesStartStop

1.1. Start and Stop SpamBayes as needed.

1.1.1. Matt Burke: dswimboy@yahoo.com

I got tired of Spam Bayes sucking up my RAM and Page File, so I wrote a V-B-Script to help me out.

I developed the script on Windows XP. I use Outlook Express and Norton Anti-Virus. You will need Windows Script Host, I think.

The script checks to see if SpamBayes is in the Processes list first. If it isn't, the script starts SpamBayes and waits (supposedly) 5 seconds. Then it starts Outlook Express. You could tweak it to start Netscape, Mozilla, or whatever other mail client you'd like to use.

Anyway, here's the code. Let me know if you have improvements please.

dim objWMI, objProcess, strProcesses, WshShell, Ret

Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}")
Set objProcess = objWMI.InstancesOf("Win32_process")
set WshShell = WScript.CreateObject("WScript.Shell")

For each Process in objProcess
        strProcesses = strProcesses & Process.Name & vbcrlf
Next

Dim regEx, Match, retVal   ' Create variable.
Set regEx = New RegExp   ' Create a regular expression.
regEx.Pattern = "sb_tray.exe"   ' Set pattern.
regEx.IgnoreCase = True   ' Set case insensitivity.
retVal = regEx.Test(strProcesses)


If retVal Then
Else
        WshShell.Exec "C:\Progra~1\SpamBayes\bin\sb_tray.exe"
        WScript.Sleep 500
End If

Ret = WshShell.Run("C:\Progra~1\Outloo~1\msimn.exe", 3, true)

Set objProcess = objWMI.InstancesOf("Win32_process")
For each Process in objProcess
        If (instr(1,lcase(Process.name),lcase("sb_tray")) > 0) then
                Process.terminate 0
        End If
Next