Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
PAB
- Posts: 139
- Joined: 12 Aug 2019 13:57
#1
Post
by PAB » 13 May 2020 06:56
Good afternoon,
Is there any way that I can do away with the
CALL cmd and incorporate it into the actual script please? . . .
Code: Select all
For /f "Tokens=*" %%G In ('wevtutil.exe el') Do (CALL :Event_Viewer_Clear_Up "%%G")
echo ^< Press ANY key to return to the Options ^> & Pause > NUL
CLS & Goto :Options
:Event_Viewer_Clear_Up
echo %1
wevtutil.exe cl %1
wevtutil.exe cl System
Thanks in advance!
Last edited by
PAB on 22 May 2020 09:25, edited 1 time in total.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 13 May 2020 09:10
What is stopping you from using wevtutil.exe in the DO portion of the FOR command?
-
PAB
- Posts: 139
- Joined: 12 Aug 2019 13:57
#3
Post
by PAB » 13 May 2020 16:04
Thanks for the reply!
I just can't seem to get it to work properly for some reason!
-
PAB
- Posts: 139
- Joined: 12 Aug 2019 13:57
#5
Post
by PAB » 14 May 2020 05:44
This is some of what I have tried . . .
Code: Select all
@echo off
for /f %%a in ('wevtutil.exe el') do wevtutil.exe el cl "%%a"
Pause
Code: Select all
@echo off
For /f %%a In ('wevtutil.exe el') Do (
wevtutil.exe echo %1 "%%a"
wevtutil.exe cl %1 "%%a"
wevtutil.exe cl System "%%a"
)
Pause
Code: Select all
@echo off
For /f %%a In ('wevtutil.exe el') Do wevtutil.exe echo %1 "%%a"
For /f %%a In ('wevtutil.exe el') Do wevtutil.exe cl %1 "%%a"
For /f %%a In ('wevtutil.exe el') Do wevtutil.exe cl System "%%a"
Pause
I obviously want it to scroll through on the cmd prompt screen like it does in the original code as it clears each item!
Thanks in advance!
-
PAB
- Posts: 139
- Joined: 12 Aug 2019 13:57
#6
Post
by PAB » 14 May 2020 06:25
OK, I think I have got it . . .
Code: Select all
@echo off
For /f "Tokens=*" %%i In ('wevtutil.exe el') Do (
rem echo wevtutil.exe cl "%%i"
echo "%%i"
wevtutil.exe cl "%%i"
wevtutil.exe cl System
)
Pause
Can you see anything
wrong please?
Thanks in advance.
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#7
Post
by ShadowThief » 14 May 2020 21:04
From an aesthetic perspective, you should indent the code inside of the for loop, but nothing bad will happen if you don't. Beyond that, I expect your code to work as you intend.
-
PAB
- Posts: 139
- Joined: 12 Aug 2019 13:57
#8
Post
by PAB » 14 May 2020 23:14
ShadowThief wrote: ↑14 May 2020 21:04
From an aesthetic perspective, you should indent the code inside of the for loop, but nothing bad will happen if you don't. Beyond that, I expect your code to work as you intend.
Do you mean something like this . . .
Code: Select all
@echo off
For /f "Tokens=*" %%i In ('wevtutil.exe el') Do (
echo "%%i"
wevtutil.exe cl "%%i"
wevtutil.exe cl System
)
Pause
Thanks in advance.