One of the most common, and well suited, applications for a command line script is to take backup of event log. Event log is necessary for troubleshooting systems. Command line scripts can be automated to run at any time without any human interaction.
How to Make a Batch File
This tutorial will help you to take a backup of event log.
Simple Batch Script:
Create Backup Directory:
First we need to create backup directory. In which we contain event log backups and log files.
C:\> MKDIR c:\Backup
C:\> MKDIR c:\BackupLogs
Backup Location: c:\Backup
Create Backup Script:
Copy and paste below script in file:
rem Script start here
rem Timestamp Generator
rem Parse the date (e.g., Tus 17/05/2016)
rem Parse the time (e.g., 11:20:56.39)
if %cur_hh% lss 10 (set cur_hh=0%time:~1,1%)
rem Set the timestamp format
wevtutil epl System %BACKUP_PATH%\system_%timestamp%.evtx
wevtutil epl Application %BACKUP_PATH%\application_%timestamp%.evtx
wevtutil epl Security %BACKUP_PATH%\security_%timestamp%.evtx
rem End of Script
Execute Batch Script:
To run the batch file, double-click on it. Once the batch file has completed running it closes automatically.