Page 1 of 1
[SOLVED] Incorporate CALL into the script.
Posted: 13 May 2020 06:56
by PAB
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!
Re: Incorporate CALL into the script.
Posted: 13 May 2020 09:10
by Squashman
What is stopping you from using wevtutil.exe in the DO portion of the FOR command?
Re: Incorporate CALL into the script.
Posted: 13 May 2020 16:04
by PAB
Thanks for the reply!
I just can't seem to get it to work properly for some reason!
Re: Incorporate CALL into the script.
Posted: 13 May 2020 16:53
by Squashman
How about you show us what you tried?
Re: Incorporate CALL into the script.
Posted: 14 May 2020 05:44
by PAB
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!
Re: Incorporate CALL into the script.
Posted: 14 May 2020 06:25
by PAB
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.
Re: Incorporate CALL into the script.
Posted: 14 May 2020 21:04
by ShadowThief
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.
Re: Incorporate CALL into the script.
Posted: 14 May 2020 23:14
by PAB
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.
Re: Incorporate CALL into the script.
Posted: 14 May 2020 23:17
by ShadowThief
Exactly
Re: Incorporate CALL into the script.
Posted: 22 May 2020 09:25
by PAB