Solved

How do modify this script to backup something other than the applications event log?

Posted on 2012-03-21
4
496 Views
Last Modified: 2012-08-14
I have the code below that backs up the applications event log, but instead of the applications event log I need it to back up a particular log file in the applications and services log (applications and service > softwarecompanyA).

How do I modify the code below to do it?

dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay

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

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='Application'")

For Each objLogfile in colLogFiles
    objLogFile.BackupEventLog("c:\scripts\" & strBackupName & _
        "_application.evt")
Next
0
Comment
Question by:Kevin Smith
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
prashanthd earned 500 total points
Comment Utility
Try following

Modify LogFile="Application" to the event log name you want to take backup example
LogFile="System"

dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
LogFile="Application"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Backup)}!\\" & _
        strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='"& logfile &"'")

For Each objLogfile in colLogFiles
    objLogFile.BackupEventLog("c:\scripts\" & strBackupName & _
        "_"&logfile&".evt")
Next

Open in new window

0
 
LVL 12

Expert Comment

by:prashanthd
Comment Utility
hmmm...Can you be more specific and give an example?
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, I'm not that familiar with the new eventing, but have a look at the discussion here:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26696817.html

Basically, it looks like the wevtutil.exe command is your utility of choice, but you could also try Powershell.  VBScript doesn't seem capable of querying these new event logs.

Rob.
0
 

Author Closing Comment

by:Kevin Smith
Comment Utility
perfect, thanks :)
0

Featured Post

Integrate social media with email signatures

Is your company active on social media? Do you also use email signatures? Including social media icons in your email signature is a great way to get fans for free. Let all your email users know you’re on social media quickly and easily, in a single click.

Join & Write a Comment

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
OfficeMate Freezes on login or does not load after login credentials are input.
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now