
I am getting errors I can't pin down
Any help would be greatly appreciated. When I run the script I get an
error in 68, which is the priveledge portion relating to reading the logs (i
think). I tried one of the MS scripts copied directly from, and it dosn't
work either. I am running the script as a domain admin. NT4 is the OS.
Any help would be greatly appreciated.
'******************************************************************
' Program: ForEachUniqueEventLogs.vbs
' Version: 0.01 Alpha
' Changes:
' Thanks To: Mark Hauschild
' : Rick Henry
' : msnews.microsoft.com
' Programmer: Edwin Holley
' Date: 11APR03
' Description: This program is designed to be run scheduled
' on a nightly basis. It will then Archive event logs into folders
' based on type of event log. The file will be name based on date,
' in military format. I will then call a log parser and mail
' important logs to my email.
'******************************************************************
Option Explicit
dim dtmThisDay, dtmThisMonth, dtmThisYear, strComputer, strBasePath
dim ClearAuditLogs, LogFile, strBackupName, strFullPath, objWMIService
Dim colLogFiles, objLogfile, strBasicPath, objFSO
'Assign Stuff
'get day month year for navy standard date format (26MAR03)
dtmThisDay = Day(Now)
dtmThisMonth = Left(Month(Now), 3)
dtmThisYear = Right(Year(Now), 2)
'Set up File System object to allow file\folder manipulation and checking
Set objFSO = CreateObject("Scripting.FileSystemObject")
'set computer to be run on "." is current
strComputer = "."
'set the base path to save the logs to
strBasePath = "E:\AuditLogs"
'creat the array for the three different type of logs
Dim AuditLogs(2)
AuditLogs(0) = "System"
AuditLogs(1) = "Security"
AuditLogs(2) = "Application"
'Set some options
ClearAuditLogs = False 'Set as a safety during debug and testing must be
true or false
'This loop chew it up and spits it out.
For Each LogFile In AuditLogs
'create string for file name
strBackupName = "" & dtmThisDay & dtmThisMonth & dtmThisYear & "_" &
LogFile & ".evt"
strBasicPath = "" & strBasePath & "\" & LogFile & " logs"
strFullPath = "" & strBasePath & "\" & LogFile & " logs\" & strBackupName
'Check existance of Folder
If objFSO.FolderExists(strBasicPath) Then
'Check the existance of file
If objFSO.FileExists(strFullPath) Then
'Inform user that file already exists, but same problem as with
directory,
'I need to incriment name, and restart from the file check 8-(
Wscript.Echo "File {" & strFullPath & "} already exist."
Else
'Set up for pull from Audit Logs, based on log is being pulled
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName=" & LogFile & "")
'Process the audit log
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog(strFullPath)
Next
'Clear Audit Log if ClearAuditLogs is true
If ClearAuditLogs Then
objLogFile.ClearEventLog()
End If
End If
Else
'Let user know that the folders don't exists
Wscript.Echo "Folder {" & strBasicPath & "} does Not exist."
'This should create the path, but I need to re-run the check folder?
'This wont't work 8-(
' ParentFolder = strBasePath
' Set objShell = CreateObject("Shell.Application")
' set objFolder = objShell.NameSpace(ParentFolder)
' objFolder.NewFolder strBasicPath
End If
Next