Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...These forums are an excellent source and example of the way people can help each other..."

Geography

Where in the world do Tek-Tips members come from?
pilgie (TechnicalUser)
2 May 06 16:24
Hi,

I am looking for a way to automatically clear and save the event logs to a file server.

Has anyone come across a tool to do this? Or has anyone done this in the past?

Any help appreciated.

Regards,

Luke.
Helpful Member!  markdmac (MIS)
3 May 06 2:02
Yup, I have a script that does it.

Save the code to a text file and name it DumpEventLogs.vbs
then schedule the script to run at whatever interval you see fit.  Don't forget to edit the destination path.


CODE


'==========================================================================
'
' NAME: DumpEventLogs.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor    
' URL: http://www.thespidersparlor.com
' DATE  : 1/12/2004
'
' COMMENT: Edit the Destination Server path below to indicate where to dump files to.  
'          Run this script on the server who's event logs are to be saved.
'
' This script and many more are included in
'               The Spider's Parlor Admin Script Pack
'==========================================================================


Dim DestServer
' Put in the UNC path for where you want the logs to be stored

DestServer = "\\backupserver\C$\Logs\"


'Create the Time variables

sDate=Right("0" & Month(Date),2) _
& "-" & Right("0" & Day(Date),2) _
& "-" & Right(Year(Date),2)

sTime = DatePart("h", Now) & DatePart("n", Now)

set oFSO = CreateObject("Scripting.FileSystemObject")


'If correct folder doesn't exist, make it

if Not oFSO.FolderExists(DestServer & sDate) then
   set oFolder = oFSO.CreateFolder(DestServer & sDate )
end if

'Gets the log files for this machine

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
        & strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile")


'This section goes out and gets the hostname this is run on for us.


Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)

For Each objItem in colItems
  strHOSTNAME = objItem.Name
NEXT


'Now archive the logs and clear them

if oFSO.FolderExists(DestServer & sDate) then
  For Each objLogfile in colLogFiles
    strBackupLog = objLogFile.BackupEventLog _
        (DestServer & sDate & "\"  & strHOSTNAME & "_" & objLogFile.LogFileName & "_" & sDate & "_" & sTime & ".evt")
    objLogFile.ClearEventLog()
  Next
end if

I hope you find this post helpful.  

Regards,

Mark

pilgie (TechnicalUser)
3 May 06 16:00
Thank you very much ******
pilgie (TechnicalUser)
3 May 06 16:08
Just testing this on my home PC which runs XP. But I recieve an invalid character error at line 1.

Will it only run on 2003. Or do i need to install something for it to run?
markdmac (MIS)
3 May 06 16:22
If line one is

Quote:


'==========================================================================

Then you probably are missing the leading apostraphe from your copy/paste.  The apostraphe indicates the code after it is a comment.

I hope you find this post helpful.  

Regards,

Mark

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close