WEVTUTIL CL fails if the event log channel has a space in it

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Yanta
Posts: 8
Joined: 01 Sep 2019 07:08

WEVTUTIL CL fails if the event log channel has a space in it

#1 Post by Yanta » 17 Mar 2020 23:06

for /f %%a in ( C:\LOGLIST.TXT ) do WEVTUTIL CL "%%a"

The textfile is created from WEVTUTIL EL >>C:\LogList.txt

For example, this:

Internet Explorer

will fail with error

Failed to clear log Internet.
The specified channel could not be found.


Whereas

HardwareEvents

Will work fine. Only happens when channel name has a space.

Any ideas why?

penpen
Expert
Posts: 1786
Joined: 23 Jun 2013 06:15
Location: Germany

Re: WEVTUTIL CL fails if the event log channel has a space in it

#2 Post by penpen » 18 Mar 2020 12:14

If you don't use any arguments in your "for/f"-loop, then the default setting is used, which is the first token (for more, see "for/?" - without the doublequotes).
This might help you:

Code: Select all

for /f "usebackq tokens=* delims=" %%a in ("C:\LOGLIST.TXT") do WEVTUTIL CL "%%a"
penpen

Yanta
Posts: 8
Joined: 01 Sep 2019 07:08

Re: WEVTUTIL CL fails if the event log channel has a space in it

#3 Post by Yanta » 22 Mar 2020 05:53

That works. Thanks for your help.

Post Reply