Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: Eleкtro en 31 Octubre 2014, 09:23 am



Título: [BATCH] Windows EventViewer Log Remover Tool
Publicado por: Eleкtro en 31 Octubre 2014, 09:23 am
Ayer tuve que utilizar el visor de eventos de Windows para obtener información de depuración de un "crash" y me encontré que tenia unos 5.000 registros de todo tipo, un coñazo para eliminarlos uno a uno, y no se pueden eliminar todos a la vez desde la GUI, el CCLEANER no limpia este tipo de basura, así que decidí escribir este pequeño Script en Batch para reciclar los registros.

Quizás a alguien más le sirva de utilidad como complemento de limpieza :P

Código
  1. @Echo OFF & Title Windows EventViewer Log Remover Tool, By Elektro.
  2.  
  3. Set "SC=%SystemRoot%\System32\SC.exe"
  4. Set "WEVTutil=%SystemRoot%\System32\WEVTutil.exe"
  5.  
  6. :: Save the current EventViewer service status.
  7. Set "Service.Status="
  8.  
  9. For /F "Tokens=3 Delims= " %%# In (
  10. 'Reg.exe Query "HKLM\SYSTEM\CurrentControlSet\Services\EventLog" /v "Start" ^| Find /I "0x"'
  11. ) Do (
  12. If "%%#" EQU "0x2" (Set "Service.Status=auto")
  13. If "%%#" EQU "0x3" (Set "Service.Status=demand")
  14. If "%%#" EQU "0x4" (Set "Service.Status=disabled")
  15. )
  16.  
  17. ( :: Start EventViewer service.
  18. "%SC%" Config "EventLog" start= "demand"
  19. "%SC%" Start  "EventLog"
  20. )1>Nul 2>&1
  21.  
  22. :: List logs and delete them.
  23. For /F "Delims=" %%# In (
  24. '"%WEVTutil%" EL'
  25. ) Do (
  26. Echo %%#
  27. "%WEVTutil%" CL "%%#"
  28. )
  29.  
  30. ( :: Stop and restore EventViewer service status.
  31. "%SC%" Stop   "EventLog"
  32. "%SC%" Config "EventLog" start= "%Service.Status%"
  33. )1>Nul 2>&1
  34.  
  35. Pause&Exit /B 0

Saludos


Título: Re: [BATCH] Windows EventViewer Log Remover Tool
Publicado por: thebatchhacker.net en 2 Noviembre 2014, 18:43 pm
Muchas gracias por la script!  ;D  ;-) ;-)


Título: Re: [BATCH] Windows EventViewer Log Remover Tool
Publicado por: Eleкtro en 3 Noviembre 2014, 11:19 am
De nada

Por cierto, los registros del Windows Event Viewer los pueden encontrar aquí:

C:\Windows\System32\winevt\Logs

Pueden verlos haciendo doble-click encima del archivo.

Saludos


Título: Re: [BATCH] Windows EventViewer Log Remover Tool
Publicado por: Wickown en 5 Noviembre 2014, 16:31 pm
Muy buena Eleкtro.


Título: Re: [BATCH] Windows EventViewer Log Remover Tool
Publicado por: FranciskoAsdf en 7 Noviembre 2014, 04:25 am
Gracias Elektro!, siempre aportando códigos útiles.!

Saludos y se guarda en la biblioteca!!!