Jump to content

Recommended Posts

Posted

Bat Script:

@echo off
FOR /F "tokens=1,2*" %%V IN ('bcdedit') DO SET adminTest=%%V
IF (%adminTest%)==(Access) goto noAdmin
for /F "tokens=*" %%G in ('wevtutil.exe el') DO (call :do_clear "%%G")
echo.
echo goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl %1
goto :eof
:noAdmin
exit

Thank you!

Posted

I spent a long time trying to convert this BAT script AU3 script, but without success, so the teacher would like to ask you, how about this BAT script written by AU3?

Posted (edited)

i2i8,

A couple things:

  

   Your topic is about as non-descriptive as is possible.

        I last used BAT processing under MSDOS 5.0.  It's changed quite a bit.  I gather that you are trying to clear the event logs.

       A title like " Clearing Event Log Batch File Conversion" would have been better.

    Post what you've tried during this "long time".

 

There are several eventlog functions that can easily do what you want.

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

  • Moderators
Posted

If you're looking to clear all event viewer logs on Windows 7, you can do something like this:

;Clear Event Viewer----------------------------------------
 
RunWait(@ComSpec & " /c wevtutil el > C:\logs.txt", @SystemDir, @SW_HIDE)

$file = "C:\Logs.txt"
Local $aLogs
 
_FileReadToArray($file, $aLogs)
_ArraySort($aLogs)
 
 For $i = 0 To UBound($aLogs) - 1
   ShellExecute("wevtutil.exe", "cl " & $aLogs[$i], @SystemDir, "", @SW_HIDE)
  Next
 
 ShellExecute("wevtutil.exe", "cl System", @SystemDir, "", @SW_HIDE)

Sleep(1000)
FileDelete($file)
;--------------------------------------------------------------------

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

I would like to know if someone still understand this syntax in 2K14  :puke:

FOR /F "tokens=1,2*" %%V IN ('bcdedit') DO SET adminTest=%%V
Posted (edited)

Okay I understood it.

I'm waiting for the OP to tell us what he's trying to achieve.

Edited by FireFox
  • 2 weeks later...
Posted

Very sorry, my dear friends!I've been busy, come back and reply to this thread until now.I just tried using the JLogan3o13 that script, but you can only clear the system log, other log cannot be cleared, for example: Application,Security,Setup,Forwarded Events.

  • Moderators
Posted

That is untrue. If you read through the script you will find that it first creates an array of every log file on the machine (504 on my machine, put an _ArrayDisplay in the code to see it). It then loops through that array and clears each one of them. If this is not working for you, it may be a permissions issue.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...