We help IT Professionals succeed at work.
Get Started

lines for the script to save a target file daily

Last Modified: 2013-11-26
Dear Experts,

I would like to be able to automatically save a Windows Security event log, only the Object Access category to monitor who deleted files/folders on our W2K3 file server.
I found below script in the EE and would like to run this script in Scheduled Tasks weekly with a yymmdd file name .

Option Explicit  
dim strComputer  
dim objWMIService  
dim colLogFiles  
dim objLogfile  
dim errBackupLog  
strComputer = "serverip" 'IP Address or Name  
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Backup)}!\\" & strComputer & "\root\cimv2")  
Call eventlogbackup("Security")  
'Call eventlogbackup("DNS Server") Define further logs here  
Function eventlogbackup(logtype)  
Set colLogFiles = objWMIService.ExecQuery ("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName='" &logtype &"'")  
For Each objLogfile in colLogFiles  
   errBackupLog = objLogFile.BackupEventLog("C:\seclogs\seclog.evt")  
   If errBackupLog <> 0 Then  
      Wscript.Echo "The " &logtype &" event log could not be backed up."  
      Wscript.Echo "The " &logtype &" event log is backed up."  
   End If  
End Function

Since I am an absolute biginner in the script stuff, any help/other recommendations to achieve my goal would be highly appreciated.

Thanks in advance.
Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE