ZimbraCoreDumpSetup.vbs

'***** ZimbraCoreDumpSetup.vbs *****
'***** v 0.4
'***** b 2006 02 27 crashdump strings, file check, log timestamp
'***** Use at your own risk :) *****



'***** CONSTANTS *****
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

Const HKCU = &H80000001
Const HKLM = &H80000002

Const FOR_APPENDING = 8
Const MINI_CRASH_DUMP_TYPE = 1
Const FULL_CRASH_DUMP_TYPE = 2

Dim crashDumpTypes(5)
crashDumpTypes(0) = "Undefined"
crashDumpTypes(MINI_CRASH_DUMP_TYPE) = "Mini dump"
crashDumpTypes(FULL_CRASH_DUMP_TYPE) = "Full dump"
bs="\"



'***** USER CONFIGURABLE SETTINGS *****
savefile = "zimbraCoreDumpOldSettings.txt"

logFilePath = "C:\Documents\debug"
crashDumpFile = "C:\Documents\debug\dump"
crashDumpType = FULL_CRASH_DUMP_TYPE

errorReportingApp = "C:\WINDOWS\SYSTEM32\DRWTSN32"


'***** GET THE SYSTEM TIMESTAMP *****
'***** awkward code part 2 *****
systemDate = "" & Date

yearString = "" & Year(systemDate)
monthString = doubleDigits( Month(systemDate) )
dayString = doubleDigits( Day(systemDate) )
dateString = yearString & " " & monthString & " " & dayString


systemTime = "" & Time
timeString = "" & FormatDateTime(systemTime, vbShortTime) & ":" & doubleDigits( Second(systemTime) )

dtString = dateString & " " & timeString




'***** GET REGISTRY ACCESS *****

dot = "."
 
Set registryAccess =GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    dot & "\root\default:StdRegProv")
 



'***** GET CURRENT SETTINGS *****
root = HKLM
output = ""

'***** show current value of error reporting app *****
path = "SOFTWARE\Microsoft\PCHealth\ErrorReporting\DW"
name = "Installed"
registryAccess.GetStringValue root,path,name,value
output = "HKLM\" & path & bs & name & ": " & value

'***** show current value of dr watson Log File Path *****
path = "SOFTWARE\Microsoft\DrWatson"
name = "LogFilePath"
registryAccess.GetStringValue root,path,name,value
output = output & vbCrLf & "HKLM\" & path & bs & name & ": " & value

'***** show current value of dr watson Crash Dump File *****
path = "SOFTWARE\Microsoft\DrWatson"
name = "CrashDumpFile"
registryAccess.GetStringValue root,path,name,value
output = output & vbCrLf & "HKLM\" & path & bs & name & ": " & value

'***** show current value of dr watson Crash Dump Type *****
path = "SOFTWARE\Microsoft\DrWatson"
name = "CrashDumpType"
registryAccess.GetDWORDValue root,path,name,value
If (value = 1) or (value = 2) Then
  'do nothing; everything is cool
Else
  value = 0
End If

output = output & vbCrLf & "HKLM\" & path & bs & name & ": " & crashDumpTypes(value)

output = output & vbCrLf




'***** SAVE CURRENT SETTINGS *****

Set fileSystemObject = CreateObject("Scripting.FileSystemObject")

'***** check for the savefile in the current directory *****
'***** awkward code alert *****
Set shellObject = CreateObject("WScript.Shell")
currentDirectory = shellObject.CurrentDirectory

Set folderObject = fileSystemObject.GetFolder(currentDirectory)
Set fileList = folderObject.Files

'***** make a regular expression that matches the savefile name *****
Set regExObject = New RegExp
regExObject.Global     = True
regExObject.IgnoreCase = False
regExObject.Pattern    = "^" & savefile & "$"

'***** check whether each file in the current directory matches the savefile name *****
fileExists = False
For Each fileObject In fileList
   matched = regExObject.Test(fileObject.Name)
   If matched Then
      fileExists = True
   End If
Next

'***** either open the file or create it if it doesn't already exist *****
If fileExists Then
  Set textfileObject = fileSystemObject.OpenTextFile(savefile,FOR_APPENDING)
Else
  Set textfileObject = fileSystemObject.CreateTextFile(savefile)
End If

textfileObject.Write dtString & vbCrLf & output




'***** DISPLAY CURRENT SETTINGS *****
Wscript.Echo "Current Settings: " & vbCrLf & vbCrLf & output




'***** ADD NEW SETTINGS *****

'***** set error reporting app *****
path = "SOFTWARE\Microsoft\PCHealth\ErrorReporting\DW"
name = "Installed"
value = errorReportingApp
registryAccess.SetStringValue root,path,name,value

'***** set dr watson Log File Path *****
path = "SOFTWARE\Microsoft\DrWatson"
name = "LogFilePath"
value = logFilePath
registryAccess.SetStringValue root,path,name,value

'***** set dr watson Crash Dump File *****
path = "SOFTWARE\Microsoft\DrWatson"
name = "CrashDumpFile"
value = crashDumpFile
registryAccess.SetStringValue root,path,name,value

'***** set dr watson Crash Dump Type *****
path = "SOFTWARE\Microsoft\DrWatson"
name = "CrashDumpType"
value = crashDumpType
registryAccess.SetDWORDValue root,path,name,value




'***** LAUNCH DRWTSN32 -i (sets dr watson as default) *****
Set shellObject = CreateObject("WScript.Shell")
shellObject.Run "drwtsn32 -i"
shellObject.Run "drwtsn32"



'***** FUNCTION: ADD LEADING ZERO IF s IS LESS THAN 10 *****
Function doubleDigits(s)
  If s < 10 Then
    s = "0" & s
  End If
  doubleDigits = s
End Function




'***** THAT'S ALL FOLKS *****


Verified Against: unknown Date Created: 5/9/2006
Article ID: https://wiki.zimbra.com/index.php?title=ZimbraCoreDumpSetup.vbs Date Modified: 2015-03-24



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search