Page 1 of 1

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

Posted: 17 Mar 2020 23:06
by Yanta
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?

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

Posted: 18 Mar 2020 12:14
by penpen
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

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

Posted: 22 Mar 2020 05:53
by Yanta
That works. Thanks for your help.