Jump to content

Bat convert Au3


i2i8
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

  • Moderators

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!

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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