Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
I want to run a batch file every couple of hours, that will take the input from a text file and put it into a field in a command I want to run.
This is the command I want to run in the batch file for every line in a txt file:
logevent -r "TEST" -e "123" "sample message for event"
The line that says "sample message for event", I want to replace that for each line in this txt file example:
2007-03-02 15:26:15 WARNING Intrusion (Bad) failed
2007-03-02 15:26:15 WARNING Power (Bad) failed
2007-03-06 19:01:27 WARNING Intrusion (Bad) failed
2007-03-06 19:01:27 WARNING Power (Bad) failedSo it would turn out like this example:
logevent -r "TEST" -e "123" "2007-03-06 19:01:27 WARNING Power (Bad) failed"
Since I am doing it every couple hours, there will me potentially multiple entries.
How can I get these txt file lines in the batch file command, entered as seperate lines?
Then I planned to use task scheduler to fire it off every couple hours.

@echo off
setLocal EnableDelayedExpansionfor /f "tokens=* delims= " %%a in (my.txt) do (
echo logevent -r "TEST" -e "123" "%%a"
)
=====================================
If at first you don't succeed, you're about average.M2

![]() |
Parsing CSV in a batch
|
count in batch
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |