elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Usando Git para manipular el directorio de trabajo, el índice y commits (segunda parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [BATCH] Windows EventViewer Log Remover Tool
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [BATCH] Windows EventViewer Log Remover Tool  (Leído 3,352 veces)
Eleкtro
Ex-Staff
*
Conectado Conectado

Mensajes: 9.788



Ver Perfil
[BATCH] Windows EventViewer Log Remover Tool
« 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


« Última modificación: 31 Octubre 2014, 11:14 am por Eleкtro » En línea

thebatchhacker.net

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Re: [BATCH] Windows EventViewer Log Remover Tool
« Respuesta #1 en: 2 Noviembre 2014, 18:43 pm »

Muchas gracias por la script!  ;D  ;-) ;-)


En línea

Eleкtro
Ex-Staff
*
Conectado Conectado

Mensajes: 9.788



Ver Perfil
Re: [BATCH] Windows EventViewer Log Remover Tool
« Respuesta #2 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
En línea

Wickown

Desconectado Desconectado

Mensajes: 128


4y7s0


Ver Perfil WWW
Re: [BATCH] Windows EventViewer Log Remover Tool
« Respuesta #3 en: 5 Noviembre 2014, 16:31 pm »

Muy buena Eleкtro.
En línea

FranciskoAsdf

Desconectado Desconectado

Mensajes: 231


Ni bueno, ni malo. Solo nada.


Ver Perfil WWW
Re: [BATCH] Windows EventViewer Log Remover Tool
« Respuesta #4 en: 7 Noviembre 2014, 04:25 am »

Gracias Elektro!, siempre aportando códigos útiles.!

Saludos y se guarda en la biblioteca!!!
En línea

Asdf debería ser algún tipo de función.
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Batch][Tool] TextToASCII - by xassiz
Scripting
xassiz_ 4 2,750 Último mensaje 23 Octubre 2009, 15:30 pm
por xassiz_
[Batch] Tool Batch Simple.
Scripting
Mr.Lerzep 7 4,204 Último mensaje 13 Noviembre 2010, 00:02 am
por Edu
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines