Author Topic: Batch Script for cleaning the Event Viewer logs in Win 7 ;)  (Read 10604 times)

0 Members and 1 Guest are viewing this topic.

Offline Darth.Mikey

  • JacobyTech Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
  • I'm a NOT a n00b da** it! ;D
    • View Profile
    • Awards
Want to clean out your Event Viewer logs ?

Here is the script:

Code: [Select]
@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

Fire up Notepad and copy/paste the script into it and save it as a *.bat file extension. When you want to run it, right click on the *.bat file and select Run as administrator. That's it, the event viewer logs are now empty.  :)
« Last Edit: June 10, 2011, 10:29:16 AM by Darth.Mikey »

Offline scythe944

  • That guy...
  • Administrator
  • JacobyTech Hero Member
  • *****
  • Posts: I am a geek!!
  • Karma: +1/-1
  • Gender: Male
    • View Profile
    • JacobyTech
    • Awards
Re: Batch Script for cleaning the Event Viewer logs in Win 7 ;)
« Reply #1 on: June 10, 2011, 12:31:52 PM »
Nice!  Guess we could add something to automatically save the event log to a file somewhere before it clears them?  I'll see if I can find that and add it in.
ANNOY A LIBERAL...
Work hard and be happy

Offline Darth.Mikey

  • JacobyTech Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
  • I'm a NOT a n00b da** it! ;D
    • View Profile
    • Awards
Re: Batch Script for cleaning the Event Viewer logs in Win 7 ;)
« Reply #2 on: June 10, 2011, 01:04:39 PM »
Interesting idea yes. Would be cool to have this. I guess you would need to look into this:

http://technet.microsoft.com/en-us/library/cc732848(WS.10).aspx

Offline scythe944

  • That guy...
  • Administrator
  • JacobyTech Hero Member
  • *****
  • Posts: I am a geek!!
  • Karma: +1/-1
  • Gender: Male
    • View Profile
    • JacobyTech
    • Awards
Re: Batch Script for cleaning the Event Viewer logs in Win 7 ;)
« Reply #3 on: June 10, 2011, 01:52:38 PM »
Thanks for the link

Ok, so here we go:

Code: [Select]
@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")
/bu:
echo.
echo goto theEnd
:do_clear
echo clearing %1
wevtutil.exe cl Application /bu:C:\EventViewerBackups\Applicationbackup.evtx %1
goto :eof
:noAdmin
exit

Maybe that would work?  I'll test it and see what it does.

edit: nope. I'll work with it later.  Does yours clear ALL event logs, or what? I don't see anything specified after the wevtutil is called in the batch file.
« Last Edit: June 10, 2011, 02:00:59 PM by scythe944 »
ANNOY A LIBERAL...
Work hard and be happy

Offline Darth.Mikey

  • JacobyTech Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
  • I'm a NOT a n00b da** it! ;D
    • View Profile
    • Awards
Re: Batch Script for cleaning the Event Viewer logs in Win 7 ;)
« Reply #4 on: June 10, 2011, 08:46:11 PM »
Well i didn't write this script(don't remember where i got it, i think w7 forums, really not sure) so i don't know what exactly you can do with this wevtutil.exe but i can tell you that the script clears ALL logs yes.


Offline scythe944

  • That guy...
  • Administrator
  • JacobyTech Hero Member
  • *****
  • Posts: I am a geek!!
  • Karma: +1/-1
  • Gender: Male
    • View Profile
    • JacobyTech
    • Awards
Re: Batch Script for cleaning the Event Viewer logs in Win 7 ;)
« Reply #5 on: June 13, 2011, 09:10:01 AM »
Gotcha.

Oh, and a little off topic but DAMN do you have a lot of hours on BattleField!
ANNOY A LIBERAL...
Work hard and be happy

Offline Darth.Mikey

  • JacobyTech Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
  • I'm a NOT a n00b da** it! ;D
    • View Profile
    • Awards
Re: Batch Script for cleaning the Event Viewer logs in Win 7 ;)
« Reply #6 on: June 13, 2011, 09:44:06 PM »
Gotcha.

Oh, and a little off topic but DAMN do you have a lot of hours on BattleField!

Yes i know, installed the game last summer and played it for 2-3 months, then stopped for 2 months and then my friends got bored with COD and i introduced them to BC2. We started a clan and have been playing almost daily since then.  Right now i should be somewhere among the top 15.000 players in the world. Considering there are alot of players out there that's not so bad i guess. Registered players for pc platform on bfbcs.com, the number is at 2 884 405 players atm and you know not everybody uses bfbcs so the number is even higher than that for sure. Have to say it's become much more fun to play now that we rented our own server. Finally i get to play the maps i like and i can ban and report those cheating n00bs...  ;D

Offline scythe944

  • That guy...
  • Administrator
  • JacobyTech Hero Member
  • *****
  • Posts: I am a geek!!
  • Karma: +1/-1
  • Gender: Male
    • View Profile
    • JacobyTech
    • Awards
Re: Batch Script for cleaning the Event Viewer logs in Win 7 ;)
« Reply #7 on: June 14, 2011, 10:23:16 AM »
Lol, you crazy man.  I don't even know if I'd want to play you, I'd get my ass handed to me.  Good way to get better though.

Having your own server is nice, I'll have to agree.  I can remember countless hours of hanging out in my Quake 3 server back in the day.  Had all sorts of fun with the settings.  Nice to be "god" of your own little part of cyberspace isn't it?  ;D
ANNOY A LIBERAL...
Work hard and be happy

Offline Darth.Mikey

  • JacobyTech Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
  • I'm a NOT a n00b da** it! ;D
    • View Profile
    • Awards
Re: Batch Script for cleaning the Event Viewer logs in Win 7 ;)
« Reply #8 on: June 14, 2011, 03:31:06 PM »
Yes my friends also don't want me in the other team lol  ;D The bad thing about being a good player is that you get called a cheater all the time and hence they keep throwing you off servers. People just don't understand that some of us are actually capable of taking down multiple opponents without dying.  You wouldn't believe how many times i got thrown off servers for taking down an entire squad, it's not my fault they can't aim for shit. Thank god i have my own server now ! And you're right it's nice to be "god" in your own little part of cyberspace, agree completely.  :)

 

anything
anything
anything