Hi guys. I would like to ask a script to make some cleanning on Windows, like: * Reg clean; * Reg defrag, if necessary; * Temp / Cookies clean (windows, browsers, etc); * Unnecessary windows files clean; * Windows update clean and reset (this one is an script already posted on this forum); * Ask to reboot. Is possible to accomplish this kind of batch script? I dont have the knowledge to do so. Please, if somebody wants to make this an MDL project, it would be nice.
I think Ccleaner already does this, or maybe it's only Pro version. I do not use it to clean registry, just temperary internet files and empty recycle bin, the only reason I have Pro Ver is lisence has not expired
Hi Lobo, I know that. What I meant is to have batch script to do the job Im seraching for something and Im ending up with some kind of crazy scripts/examples, as follow: cd C:\Users\%username%\AppData\Local rmdir /S /Q Temp del C:\Windows\Prefetch\*.* /Q del C:\Windows\Temp\*.* /Q del C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Recent Items*.* /Q pause *********************************************************************** echo Limpando arquivos temporarios e cookies de internet del /f /q "%userprofile%\Cookies\*.*" cls del /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" cls echo Limpando disco if exist "C:\WINDOWS\temp"del /f /q "C:WINDOWS\temp\*.*" if exist "C:\WINDOWS\tmp" del /f /q "C:\WINDOWS\tmp\*.*" if exist "C:\tmp" del /f /q "C:\tmp\*.*" if exist "C:\temp" del /f /q "C:\temp\*.*" if exist "%temp%" del /f /q "%temp%\*.*" if exist "%tmp%" del /f /q "%tmp%\*.*" if exist C:\WINDOWS\Users\AppData\Temp\*.zip del C:\WINDOWS\Users\Users\*.zip /f /q if exist C:\WINDOWS\ShellIconCache del /f /q "C:\WINDOWS\ShellI~1\*.*" cls exit Set UserProfilePath=%FolderName% Call :RemoveSubfoldersAndFiles %UserProfilePath%\Local Settings\Temp Call :RemoveSubfoldersAndFiles %UserProfilePath%\Local Settings\Temporary Internet Call :RemoveSubfoldersAndFiles %UserProfilePath%\Application Data\Sun\Java\Deployment\cache Call :RemoveSubfoldersAndFiles %UserProfilePath%\AppData\Local\Temp Call :RemoveSubfoldersAndFiles %UserProfilePath%\AppData\LocalLow\Temp Call :RemoveSubfoldersAndFiles %UserProfilePath%\AppData\LocalLow\Sun\Java\Deployment\cache Call :RemoveSubfoldersAndFiles %UserProfilePath%\AppData\Local\Microsoft\Windows\Temporary Internet Files *********************************************** @echo off IF EXIST c:\windows\temp\ del /f /s /q c:\windows\temp\ DEL /f /s /q %temp%\ DEL C:\Windows\Prefetch*.* /Q DEL C:\Windows\Temp*.* /Q DEL C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Recent Items*.* /Q IF EXIST "C:\Users" ( for /D %%x in ("C:\Users\*") do ( del /f /s /q "%%x\AppData\Local\Temp" del /f /s /q "%%x\AppData\Local\Microsoft\Windows\Temporary Internet Files" ) ) IF EXIST "C:\Documents and Settings" ( for /D %%x in ("C:\Documents and Settings\*") do ( del /f /s /q "%%x\Local Settings\Temp" del /f /s /q "%%x\Local Settings\Temporary Internet Files" ) ) *********************************************** Its just some sketchs.. Im looking into these lines and trying to figuire out how to accomplish.. some help would be great... EDIT.: I would like to have all of these lines in a batch script to clean all these things but showing informations about the tasks and, at the end, show a message about all tasks finished and ask the user to reboot the computer... If somebody could help, please, do so..
well yro first log in on MDL after search the section named as MDL Projects and Applications scrow down til encounter the thread DISM++ then make download this file and read with very attention how to use it and finally I'm not resposible for you make mistakes or wrong things right damaging your system
Ok, so.. Im trying to unite everything and Im here: Code: echo CLEAN THINGS!!! del /f /q "%userprofile%\Cookies\*.*" del /f /q "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" cls if exist "C:\WINDOWS\temp"del /f /q "C:WINDOWS\temp\*.*" if exist "C:\WINDOWS\tmp" del /f /q "C:\WINDOWS\tmp\*.*" if exist "C:\tmp" del /f /q "C:\tmp\*.*" if exist "C:\temp" del /f /q "C:\temp\*.*" if exist "%temp%" del /f /q "%temp%\*.*" if exist "%tmp%" del /f /q "%tmp%\*.*" if exist "C:\WINDOWS\ShellIconCache\" del /f /q "C:\WINDOWS\ShellI~1\*.*" cls if exist "%UserProfilePath%\Local Settings\Temp\" del /f /s /q "%UserProfilePath%\Local Settings\Temp\" if exist "%UserProfilePath%\Local Settings\Temporary Internet\" del /f /s /q "%UserProfilePath%\Local Settings\Temporary Internet\" if exist "%UserProfilePath%\Application Data\Sun\Java\Deployment\cache\" del /f /s /q "%UserProfilePath%\Application Data\Sun\Java\Deployment\cache\" if exist "%UserProfilePath%\AppData\Local\Temp\" del /f /s /q "%UserProfilePath%\AppData\Local\Temp\" if exist "%UserProfilePath%\AppData\LocalLow\Temp\" del /f /s /q "%UserProfilePath%\AppData\LocalLow\Temp\" if exist "%UserProfilePath%\AppData\LocalLow\Sun\Java\Deployment\cache\" del /f /s /q "%UserProfilePath%\AppData\LocalLow\Sun\Java\Deployment\cache\" if exist "%UserProfilePath%\AppData\Local\Microsoft\Windows\Temporary Internet Files\" del /f /s /q "%UserProfilePath%\AppData\Local\Microsoft\Windows\Temporary Internet Files\" cls DEL C:\Windows\Prefetch*.* /Q DEL C:\Windows\Temp*.* /Q DEL C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Recent Items*.* /Q cls echo All clean. Reboot now!!! pause Is this correct? Somebody help!!! Please!!! :3
Be sure to make backup copy or system restore point just in case you need it. I think task scheduler will write script for you:
If you dislike it so much, why run it, and why come over here and complain constantly, We did not write OS, please direct your dislikes of OS to MS, we're just trying to get by with what they furnish us your bitching to the wrong people
Im using this from time to time, especially after large windows updates. Code: @echo offtitle . color 1F openfiles >nul 2>&1 if %errorlevel% NEQ 0 goto :UACPrompt goto :gotAdmin :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~fs0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" exit /b :gotAdmin DEL /S /F /Q "%temp%\*" 1>nul 2>nul DEL /S /F /Q %systemroot%\temp\* 1>nul 2>nul DEL /S /F /Q %systemroot%\inf\*.log 1>nul 2>nul DEL /S /F /Q %systemroot%\Logs\CBS\* 1>nul 2>nul DEL /S /F /Q %systemroot%\Logs\DPX\* 1>nul 2>nul DEL /S /F /Q %systemroot%\Logs\DISM\* 1>nul 2>nul DEL /S /F /Q %systemroot%\Microsoft.NET\Framework\v2.0.50727\*.log 1>nul 2>nul DEL /S /F /Q %systemroot%\Microsoft.NET\Framework\v4.0.30319\*.log 1>nul 2>nul if exist %systemroot%\SysWOW64\cmd.exe DEL /S /F /Q %systemroot%\Microsoft.NET\Framework64\v2.0.50727\*.log 1>nul 2>nul if exist %systemroot%\SysWOW64\cmd.exe DEL /S /F /Q %systemroot%\Microsoft.NET\Framework64\v4.0.30319\*.log 1>nul 2>nul DEL /S /F /Q %systemroot%\SoftwareDistribution\Download\* 1>nul 2>nul RD /S /Q "%LocalAppData%\Microsoft\Windows\WER\ReportQueue" 1>nul 2>nul for /f %%i in ('"dir /s /b /ad "%temp%"" 2^>nul') do RD /S /Q %%i 1>nul 2>nul for /f %%i in ('"dir /s /b /ad %windir%\SoftwareDistribution\Download" 2^>nul') do RD /S /Q %%i 1>nul 2>nul for /f %%i in ('"dir /s /b /ad %windir%\temp" 2^>nul') do RD /S /Q %%i 1>nul 2>nul
I like this!! I'm not a coder I like it to the fact that it really clean unnecessary files from my computer. Thanks!
I use this code after every Windows update (every 2 weeks) plus WiseCare and I turn off PC with CCleaner daily. Code: cipher /d /s:C:\ fsutil usn deletejournal /d /n c: chkdsk /scan compact /CompactOs:never winmgmt /salvagerepository del "%temp%\*" /s /f /q del "C:\$Recycle.bin\*" /s /f /q del "D:\$Recycle.bin\*" /s /f /q del "E:\$Recycle.bin\*" /s /f /q del "%systemroot%\temp\*" /s /f /q vssadmin delete shadows /for=c: /all /quiet Dism /Online /Cleanup-Image /CheckHealth Dism /Online /Cleanup-Image /StartComponentCleanup /ResetBase cleanmgr /sageset:65535 & cleanmgr /sagerun:65535 You can easily add CCleaner to it, like: Code: taskkill /f /im dllhost.exe start "" "C:\Program Files\CCleaner\CCleaner64.exe" /AUTO I defrag system drive outside Windows, obviously. Code: Boot Windows USB - Repair - Troubleshoot - CMD - type/enter c: cd windows cd system32 defrag c: /d /u
First at all, I'm from Argentina so I speak Spanish and just a little english so please excuse my lack of vocabulary or grammatical mistakes. I learned vbs a few years back to be able to program some scripts at work. I know powershell is a lot better, but I work in a large public organization with thousands of computers which most uses XP and doesn't have it enabled. But I think it works very well from XP to W10. Some warnings though... because I speak spanish and most of my co-workers doesn't know english, most of the functions, variables and code clarifications are in spanish. Some folders locations are localized in XP, so that part of the code will not work in other languages, but I think it's very easy to fix. The code is very modular, every action is done by some function, so it's very easy to disable or modify. The manual deletion part is done with some dictionary objects, a recursive function that goes through all the folders saving the path info, and then the delete part is executed. It's made that way on purpose to be able to generate some detailed log, and because Windows behave pretty stupid and dumb if it encounters a locked file in between. Well, my vbs script do this: - Manually deletes files from this folders: Spoiler: Folders $RECICLER.BIN Recycler Recycled Temp ProgramData\Microsoft\Windows\WER ProgramData\Microsoft\Windows Defender\Scans\History\Results Program Files\Google\Update\Download Windows\Debug Windows\Logs Windows\MiniDump Windows\pchealth\ERRORREP Windows\Prefetch Windows\Security\Logs Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Media Player\Art Cache Windows\SoftwareDistribution\Download Windows\SoftwareDistribution\DataStore\Logs Windows\System32\spool\Printers Windows\System32\Wbem\Logs Windows\Temp Windows\$*$ Windows\ie7updates Windows\ie8updates Windows\*.log AppData\Local\Downloaded Installations AppData\Local\Google\Chrome\User Data\Default\Cache AppData\Local\Microsoft\Media Player AppData\Local\Microsoft\Messenger AppData\Local\Microsoft\Windows Live Contacts AppData\Local\Microsoft\Windows\Burn AppData\Local\Microsoft\Windows\Explorer AppData\Local\Microsoft\Windows\History AppData\Local\Microsoft\Windows\Temporary Internet Files AppData\Local\Mozilla\Firefox\Profiles AppData\Local\Opera\Opera\Cache AppData\Local\Opera Software\Opera Stable\Cache AppData\Local\Opera Software\Opera Stable\Media Cache AppData\Local\Temp AppData\Local\Thunderbird\Profiles AppData\Local\Thunderbird\Updates AppData\LocalLow\Microsoft\CryptnetUrlCache AppData\LocalLow\Sun\Java\Deployment\cache AppData\LocalLow\Sun\Java\Deployment\javaws\cache AppData\LocalLow\Sun\Java\Deployment\SystemCache AppData\Roaming\Adobe\Flash Player\AssetCache AppData\Roaming\Macromedia\Flash Player AppData\Roaming\Microsoft\Windows\Cookies AppData\Roaming\Microsoft\Windows\Recent AppData\Roaming\Microsoft\Word AMD cpqs Dell Drivers Hotfix i386 Intel Lexmark PerfLogs Recovery SYSTEM.SAV Xerox - Runs this Windows utilities: Cleanmgr (Windows Clean Manager) - Automatically select all tasks except this two: Office Setup Files and Compress old Files. Only safe way to delete WU backups from W7 and above. Dism - Deletes Services Packs backups from W7 and above Vssadmin - Deletes recoverys Wevutil - Deletes event registry logs. - Stops and restart some windows services to be able to delete some files. - Needs to be run as Administrator, and elevated in W10. (cmd -> right button - > run as administrator) - Creates some txt log in the desktop and shows a popup with the space made and the time it took to complete. - Disables Hibernation. EDIT 2019-03-11: Updated version of my previous script. Changelog: - My script can be run in 3 modes now: full, without windows utilities, and offline mode. To be able to do that, you need to set to True one of the constants that are defined in lines 20 and 21: kNO_UTILS = True - It disables all Windows utilities, wich speeds a lot the execution if you don't need it. kOFFLINE = True - It's intended to be used when you need to clear temps in an offline operative system (slave disk) before you perform a user backup. I think it should be possible to run it in WinPE environment, if WSH and WMI are included. kNO_UTILS is implicit in this case, no need to set it too. - Windows XP localized folders are now defined in constants at lines 61 to 67, so it's more easy to change it in case you need it. - All dialogs are defined in constants too, from lines 70 to 141, so it's more "translation friendly" if anyone want's/needs to translate it to their language. - CLENMGR utility now excludes all these tasks: Office Setup Files, Compress Old Files, Compress System Disk, Users Download Folder and DownloadsFolder. - Small code changes. BORRA_TEMPS.vbs Code: '************************************************************************************************************** 'Nombre del Script : BORRA_TEMPS.vbs 'Versión : v1.35 'Autor : NTurky 'Creado el : 01/09/2015 'Modificado : 11/03/2019 'Descripcion : Borra archivos temporales de carpetas en la raíz del disco, carpetas del sistema y dentro ' del profile de los usuarios. ' Utiliza las herramientas de Windows CLEANMGR.exe, DISM.exe, VSSADMIN.exe y WEVTUTIL.exe. ' También deshabilita la hibernación si se encuentra activada. '************************************************************************************************************** Option Explicit '************************************************************************************************************** ' CONSTANTES '************************************************************************************************************** Const kVER = "v1.35" Const kTITULO = "BorraTemps" Const kFLAG = "69" Const kLOGEXTENDIDO = True 'TRUE para archivo de LOG detallado Const kOFFLINE = False 'TRUE para modo Offline. Const kNO_UTILS = False 'TRUE para deshabilitar utilidades. 'Constantes para ejecución de utilidades Const kESPERAR = True Const kSEGUIR = False Const kMOSTRAR = 1 Const kOCULTAR = 0 Const kDECIMALES = 2 Const kAGRUPAR = -1 ' True = -1 , False = 0 , Default = -2 Const kKBYTES = 1024 Const kMBYTES = 1048576 Const kGBYTES = 1073741824 'Constantes de archivos Const kLECTURA = 1 Const kESCRITURA = 2 Const kAGREGAR = 0 'Constantes para la función BorradoManual Const kCARPETAS = True Const kARCHIVOS = False 'Constantes para la función RecorreCarpetas Const kCOMPLETA = True Const kCONTENIDO = False 'Constantes para la función ModificaServicio Const kFINALIZAR = True Const kINICIAR = False Const kTIMEOUT = 600 'segundos x 10 'Constantes para el registro de Windows Const HKCR = &H80000000 ' HKEY_CLASSES_ROOT Const HKCU = &H80000001 ' HKEY_CURRENT_USER Const HKLM = &H80000002 ' HKEY_LOCAL_MACHINE Const HKUS = &H80000003 ' HKEY_USERS Const HKCC = &H80000005 ' HKEY_CURRENT_CONFIG 'Carpetas de Windows XP Const kXP_Application_Data = "Datos de programa" Const kXP_Cookies = "Cookies" Const kXP_Documents_and_settings = "Documents and Settings" Const kXP_History = "Historial" Const kXP_Local_Settings = "Configuración local" Const kXP_Recent = "Reciente" Const kXP_Temporary_Internet_Files = "Archivos temporales de Internet" 'Textos Const T_MSG_ADMIN_01 = "El Script debe ser ejecutado" Const T_MSG_ADMIN_02 = "con derechos de Administrador!" Const T_MSG_AS = "archivos" Const T_MSG_BM_AB = "Borrando archivos" Const T_MSG_BM_AS = "archivos seleccionados para su eliminación" Const T_MSG_BM_CB = "Borrando carpetas" Const T_MSG_BM_CREA = "Creando listado de archivos y carpetas a eliminar" Const T_MSG_BM_CS = "carpetas seleccionadas para su eliminación" Const T_MSG_BM_FIN = "Secuencia de borrado manual finalizada" Const T_MSG_BM_INI = "Iniciando secuencia de borrado manual" Const T_MSG_BYTES = "Bytes" Const T_MSG_CHAR_1 = "*****" Const T_MSG_CHAR_2 = "=====" Const T_MSG_CHAR_3 = ">>>>>" Const T_MSG_CS = "carpetas" Const T_MSG_E_C = "Capacidad del disco" Const T_MSG_E_IP = "Inicio del proceso" Const T_MSG_E_N = "Nombre de equipo" Const T_MSG_E_U = "Unidad procesada" Const T_MSG_EF = "ELIMINADA" Const T_MSG_EL = "Espacio liberado" Const T_MSG_EM = "ELIMINADO" Const T_MSG_ERR = "Error" Const T_MSG_ERR_L = "El archivo log no pudo ser creado! Disco lleno?" Const T_MSG_ERR_R = "Error al intentar restablecer la opción" Const T_MSG_ERR_S = "Error al intentar seleccionar la opción" Const T_MSG_ES = "Se eliminaron" Const T_MSG_EX = "Ejecutando la utilidad" Const T_MSG_F_EL = "Total de espacio liberado" Const T_MSG_F_ELF = "Espacio libre al terminar" Const T_MSG_F_ELI = "Espacio libre al iniciar" Const T_MSG_F_FP = "Fin del proceso" Const T_MSG_GBYTES = "GBytes" Const T_MSG_H_D = "La hibernación ha sido deshabilitada" Const T_MSG_H_ND = "La hibernación no pudo ser deshabilitada" Const T_MSG_KBYTES = "KBytes" Const T_MSG_MBYTES = "MBytes" Const T_MSG_MO_ER = "Debe ingresar una unidad válida!" Const T_MSG_MO_IN = "Ingrese letra de unidad a procesar: " Const T_MSG_MO_IE = "Ej: C, D, etc." Const T_MSG_NES = "no pudieron eliminarse" Const T_MSG_NOU = "UTILIDADES DESHABILITADAS" Const T_MSG_NPSF = "NO PUDO SER ELIMINADA" Const T_MSG_NPSM = "NO PUDO SER ELIMINADO" Const T_MSG_OFF = "MODO OFFLINE" Const T_MSG_OR = "Opción restablecida" Const T_MSG_OS = "Opción seleccionada" Const T_MSG_SV = "El servicio" Const T_MSG_SV_D = "ha sido detenido" Const T_MSG_SV_DS = "Deteniendo servicios" Const T_MSG_SV_ED = "estaba detenido" Const T_MSG_SV_EI = "estaba iniciado" Const T_MSG_SV_I = "ha sido iniciado" Const T_MSG_SV_IS = "Iniciando servicios" Const T_MSG_SV_ND = "no pudo ser detenido" Const T_MSG_SV_NI = "no pudo ser iniciado" Const T_MSG_TC = "finalizó correctamente" Const T_MSG_TE = "Tiempo empleado" Const T_MSG_TER = "finalizó con error" Const T_MSG_UTIL_C = "La utilidad CLEANMGR" Const T_MSG_UTIL_C_INI = "Iniciando la utilidad CLEANMGR" Const T_MSG_UTIL_D = "La utilidad DISM" Const T_MSG_UTIL_D_INI = "Iniciando la utilidad DISM" Const T_MSG_UTIL_V = "La utilidad VSSADMIN" Const T_MSG_UTIL_V_INI = "Iniciando la utilidad VSSADMIN" Const T_MSG_UTIL_W = "La utilidad WEVTUTIL" Const T_MSG_UTIL_W_CREA = "Creando listado de registros a eliminar" Const T_MSG_UTIL_W_INI = "Iniciando utilidad WEVTUTIL" Const T_MSG_UTIL_W_RE = "Registros eliminados" Const T_MSG_UTIL_W_RS = "registros seleccionados para su eliminación" Const T_MSG_UTIL_W_RER = "no fueron eliminados" Const T_MSG_UTIL_W_TR = "Total de registros" '************************************************************************************************************** ' DECLARACIONES '************************************************************************************************************** Dim kESPACIOS : kESPACIOS = vbCrLf Dim dtmTiempoFin, strTiempoEmp Dim intEspLibIni, intEspLibFin, intEsp Dim strLogNom, strLogRuta, strOS Dim dtmTiempoInicio : dtmTiempoInicio = Time Dim intCArch : intCArch = 0 Dim intCCarp : intCCarp = 0 Dim objArchLog Dim dicArchivos : Set dicArchivos = CreateObject("Scripting.Dictionary") Dim dicCarpetas : Set dicCarpetas = CreateObject("Scripting.Dictionary") Dim objFS : Set objFS = CreateObject("Scripting.FileSystemObject") Dim objShell : Set objShell = CreateObject("WScript.Shell") Dim objDisco : Set objDisco = objFS.GetDrive(objShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")) Dim strEquipo : strEquipo = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%") Dim strUnidad : strUnidad = objShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%") & "\" Dim strUsuarios : strUsuarios = objFS.GetParentFolderName(objShell.ExpandEnvironmentStrings("%USERPROFILE%")) Dim objReg : Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _ & strEquipo & "\root\default:StdRegProv") '************************************************************************************************************** ' PROGRAMA PRINCIPAL '************************************************************************************************************** If Not EsAdmin Then objShell.Popup T_MSG_ADMIN_01 & vbNewLine & T_MSG_ADMIN_02,, kTITULO & " " & kVER, VBCritical WScript.Quit 1 End If If kOFFLINE Then ModoOffline If CreaArchivo Then intEspLibIni = objDisco.FreeSpace CheckSO Borrar DeshabilitaHibernacion dtmTiempoFin = Time strTiempoEmp = TiempoTranscurrido (dtmTiempoInicio, dtmTiempoFin) intEspLibFin = objDisco.FreeSpace intEsp = intEspLibFin - intEspLibIni Finalizar objShell.Popup T_MSG_EL & ": " & Unidades(intEsp) & vbNewLine &_ T_MSG_TE & " : " & strTiempoEmp, 5, kTITULO & " " & kVER, VBInformation Set objShell = Nothing Else WScript.Echo T_MSG_ERR_L End If '************************************************************************************************************** ' FUNCIONES '************************************************************************************************************** Sub BorraCarpetas(dic, booCarpetas) Dim arrDatos : arrDatos = dic.Items Dim booBorrado Dim intInd Dim intCC : intCC = 0 Dim intCE : intCE = 0 Dim intTam Dim strElementos, strEstado, strPath, strResultado Dim objElementos If booCarpetas Then strElementos = T_MSG_CS strEstado = T_MSG_EF Else strElementos = T_MSG_AS strEstado = T_MSG_EM End If 'Agrego un Do ... While False para poder saltar a la próxima iteración del bucle For 'en el caso de que una subcarpeta no exista porque fue eliminada con la carpeta raíz 'que la contenía. For intInd = 0 To dic.count - 1 : Do On Error Resume Next If booCarpetas Then 'Agrego esta comprobación para que la información del borrado de carpetas 'del log sea correcta. If objFS.FolderExists(arrDatos(intInd)) Then Set objElementos = objFS.GetFolder(arrDatos(intInd)) Else If kLOGEXTENDIDO Then Salida EstiloNum(intInd + 1, Len(doc.count)) & " - " & arrDatos(intInd) & " - " & Unidades(0) & " - " & strEstado End If intCC = intCC + 1 Exit Do End If Else Set objElementos = objFS.GetFile(arrDatos(intInd)) End If strPath = objElementos.Path intTam = objElementos.Size objElementos.Delete(True) If Err.Number = 0 Then intCC = intCC + 1 booBorrado = True Else intCE = intCE + 1 booBorrado = False Err.Clear End If On Error Goto 0 If kLOGEXTENDIDO Then strResultado = EstiloNum(intInd + 1, Len(dic.count)) & " - " & strPath & " - " & Unidades(intTam) If booBorrado Then strResultado = strResultado & " - " & strEstado Else If booCarpetas Then strResultado = strResultado & " - " & T_MSG_NPSF Else strResultado = strResultado & " - " & T_MSG_NPSM End If End If Salida strResultado End If Set objElementos = Nothing Loop While False : Next Salida T_MSG_ES & " " & intCC & " " & strElementos Salida "(" & intCE & " " & strElementos & " " & T_MSG_NES & ")" End Sub Sub BorradoManual Dim intEspIni : intEspIni = objDisco.FreeSpace Dim intEspFin Dim dtmTI : dtmTI = Time Salida T_MSG_CHAR_3 & " " & T_MSG_BM_INI Salida T_MSG_BM_CREA & ".." ElementosParaBorrar Salida dicArchivos.count & " " & T_MSG_BM_AS Salida dicCarpetas.count & " " & T_MSG_BM_CS Salida T_MSG_CHAR_3 & " " & T_MSG_BM_AB & ".." BorraCarpetas dicArchivos, kARCHIVOS Salida T_MSG_CHAR_3 & " " & T_MSG_BM_CB & ".." BorraCarpetas dicCarpetas, kCARPETAS intEspFin = objDisco.FreeSpace - intEspIni Salida T_MSG_CHAR_3 & " " & T_MSG_BM_FIN Salida T_MSG_CHAR_3 & " " & T_MSG_TE & " : " & TiempoTranscurrido(dtmTI, Time) Salida T_MSG_CHAR_3 & " " & T_MSG_EL & ": " & Unidades(intEspFin) Salida kESPACIOS Set dicArchivos = Nothing Set dicCarpetas = Nothing End Sub Sub Borrar Dim dtmTiempoIni : dtmTiempoIni = Time If Not kOFFLINE Then Salida T_MSG_SV_DS & ".." ModificaServicio "wuauserv", kFINALIZAR ModificaServicio "TrustedInstaller", kFINALIZAR ModificaServicio "Spooler", kFINALIZAR Salida kESPACIOS End If BorradoManual If kOFFLINE Then Exit Sub If Not kNO_UTILS Then UtilidadCleanmgr If strOS = "NT" Then UtilidadDism UtilidadVssadmin UtilidadWevtutil End If End If Salida T_MSG_SV_IS & ".." ModificaServicio "wuauserv", kINICIAR ModificaServicio "TrustedInstaller", kINICIAR ModificaServicio "Spooler", kINICIAR Salida kESPACIOS End Sub Sub CheckSO If kOFFLINE Then Exit Sub Dim strReg : strReg = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion") If Cint(Left(strReg,1)) > 5 Then strOS = "NT" Else strOS = "NT5" End If End Sub Function CreaArchivo CreaArchivo = False strLogNom = kTITULO & "-" & strEquipo & "-" & Year(Date) & EstiloNum(Month(Date), 2) & EstiloNum(Day(Date), 2) _ & "-" & EstiloNum(Hour(dtmTiempoInicio), 2) & EstiloNum(Minute(dtmTiempoInicio), 2) _ & EstiloNum(Second(dtmTiempoInicio), 2) & ".log" strLogRuta = objShell.SpecialFolders("Desktop") & "\" & strLogNom Set objArchLog = objFS.OpenTextFile(strLogRuta, kESCRITURA, True) If objFS.FileExists(strLogRuta) Then CreaArchivo = True Encabezado End If End Function Sub DeshabilitaHibernacion If kOFFLINE Then Exit Sub Dim strCmd Dim strArchivo : strArchivo = "hiberfil.sys" If objFS.FileExists(strUnidad & strArchivo) Then If strOS = "NT" Then strCmd = "cmd /c powercfg -h off" Else strCmd = "cmd /c powercfg /h off" End If On Error Resume Next objShell.Run strCmd, kOCULTAR, kESPERAR If Err.Number = 0 Then Salida T_MSG_H_D Else Salida T_MSG_H_ND Err.Clear End If On Error Goto 0 End If End Sub Sub ElementosParaBorrar Dim booUpdates Dim intInd Dim strUsuario, strPerfil Dim objUsuarios, objUsuario, objCarpeta, objSubCarpeta, objArchivo Dim arrCarpRaiz, arrCarpSis, arrCarpUsr On Error Resume Next 'Carpetas del sistema arrCarpSis = Array("$RECICLER.BIN",_ "Recycler",_ "Recycled",_ "Temp",_ "ProgramData\Microsoft\Windows\WER",_ "ProgramData\Microsoft\Windows Defender\Scans\History\Results",_ "Program Files\Google\Update\Download",_ "Windows\Debug",_ "Windows\Logs",_ "Windows\MiniDump",_ "Windows\pchealth\ERRORREP",_ "Windows\Prefetch",_ "Windows\Security\Logs",_ "Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Media Player\Art Cache",_ "Windows\SoftwareDistribution\Download",_ "Windows\SoftwareDistribution\DataStore\Logs",_ "Windows\System32\spool\Printers",_ "Windows\System32\Wbem\Logs",_ "Windows\Temp") For intInd = LBound(arrCarpSis) to UBound(arrCarpSis) RecorreCarpetas strUnidad & arrCarpSis(intInd), kCONTENIDO Next If kOFFLINE Then Set objCarpeta = objFS.GetFolder(strUnidad & "Windows") Else Set objCarpeta = objFS.GetFolder(objShell.ExpandEnvironmentStrings("%WINDIR%")) End If 'Actualizaciones de Windows XP If strOS = "NT5" Then For Each objSubCarpeta in objCarpeta.SubFolders booUpdates = False If Left(objSubCarpeta.Name, 1) = "$" And Right(objSubCarpeta.Name, 1) = "$" Then booUpdates = True Elseif objSubCarpeta.Name = "ie7updates" Or objSubCarpeta.Name = "ie8updates" Then booUpdates = True End If If booUpdates Then RecorreCarpetas objSubCarpeta.Path, kCOMPLETA End If Next End If 'Archivos Log en Carpeta Windows For Each objArchivo in objCarpeta.Files If LCase(objFS.GetExtensionName(objArchivo.Name)) = "log" Then dicArchivos.add intCArch, objArchivo.Path intCArch = intCArch + 1 End If Next Set objCarpeta = Nothing Set objSubCarpeta = Nothing Set objArchivo = Nothing 'Carpetas de los usuarios Set objUsuarios = objFS.GetFolder(strUsuarios) For Each objUsuario in objUsuarios.SubFolders strUsuario = objUsuario.Path & "\" If strOS = "NT" Then 'carpetas para 7+ arrCarpUsr = Array("AppData\Local\Downloaded Installations",_ "AppData\Local\Google\Chrome\User Data\Default\Cache",_ "AppData\Local\Microsoft\Media Player",_ "AppData\Local\Microsoft\Messenger",_ "AppData\Local\Microsoft\Windows Live Contacts",_ "AppData\Local\Microsoft\Windows\Burn",_ "AppData\Local\Microsoft\Windows\Explorer",_ "AppData\Local\Microsoft\Windows\History",_ "AppData\Local\Microsoft\Windows\Temporary Internet Files",_ "AppData\Local\Mozilla\Firefox\Profiles",_ "AppData\Local\Opera\Opera\Cache",_ "AppData\Local\Opera Software\Opera Stable\Cache",_ "AppData\Local\Opera Software\Opera Stable\Media Cache",_ "AppData\Local\Temp",_ "AppData\Local\Thunderbird\Updates",_ "AppData\LocalLow\Microsoft\CryptnetUrlCache",_ "AppData\LocalLow\Sun\Java\Deployment\cache",_ "AppData\LocalLow\Sun\Java\Deployment\javaws\cache",_ "AppData\LocalLow\Sun\Java\Deployment\SystemCache",_ "AppData\Roaming\Adobe\Flash Player\AssetCache",_ "AppData\Roaming\Macromedia\Flash Player",_ "AppData\Roaming\Microsoft\Windows\Cookies",_ "AppData\Roaming\Microsoft\Windows\Recent",_ "AppData\Roaming\Microsoft\Word") Else 'carpetas para XP arrCarpUsr = Array(kXP_Application_Data & "\Adobe\Flash Player\AssetCache",_ kXP_Application_Data & "\Macromedia\Flash Player",_ kXP_Application_Data & "\Microsoft\CryptnetUrlCache",_ kXP_Application_Data & "\Microsoft\Word",_ kXP_Application_Data & "\Opera\Opera\Cache",_ kXP_Application_Data & "\Opera Software\Opera Stable\Cache",_ kXP_Application_Data & "\Opera Software\Opera Stable\Media Cache",_ kXP_Application_Data & "\Sun\Java\Deployment\cache",_ kXP_Application_Data & "\Sun\Java\Deployment\javaws\cache",_ kXP_Application_Data & "\Sun\Java\Deployment\SystemCache",_ kXP_Local_Settings & "\" & kXP_Application_Data & "\Google\Chrome\User Data\Default\Cache",_ kXP_Local_Settings & "\" & kXP_Application_Data & "\Mozilla\Firefox\Profiles",_ kXP_Local_Settings & "\" & kXP_Application_Data & "\Thunderbird\Updates",_ kXP_Local_Settings & "\" & kXP_Application_Data & "\Microsoft\Media Player\Art Cache",_ kXP_Local_Settings & "\Temp",_ kXP_Local_Settings & "\" & kXP_Temporary_Internet_Files,_ kXP_Local_Settings & "\" & kXP_History,_ kXP_Recent,_ kXP_Cookies) End If For intInd = LBound(arrCarpUsr) to UBound(arrCarpUsr) RecorreCarpetas strUsuario & arrCarpUsr(intInd), kCONTENIDO Next 'Temporales Thunderbird If strOS = "NT" Then strPerfil = strUsuario & "AppData\Local\Thunderbird\Profiles\" Else strPerfil = strUsuario & kXP_Local_Settings & "\" & kXP_Application_Data & "\Thunderbird\Profiles" End If If objFS.FolderExists(strPerfil) Then Set objCarpeta = objFS.GetFolder(strPerfil) For Each objSubCarpeta in objCarpeta.SubFolders If objFS.FolderExists(objSubCarpeta.Path & "\" & "Cache") Then RecorreCarpetas objSubCarpeta.Path & "\" & "Cache", kCONTENIDO End If If objFS.FolderExists(objSubCarpeta.Path & "\" & "cache2") Then RecorreCarpetas objSubCarpeta.Path & "\" & "cache2", kCONTENIDO End If If objFS.FolderExists(objSubCarpeta.Path & "\" & "startupCache") Then RecorreCarpetas objSubCarpeta.Path & "\" & "startupCache", kCONTENIDO End If Next End If Set objCarpeta = Nothing Set objSubCarpeta = Nothing Next Set objUsuarios = Nothing Set objUsuario = Nothing Set objArchivo = Nothing 'Carpetas en raiz arrCarpRaiz = Array("AMD",_ "cpqs",_ "Dell",_ "Drivers",_ "Hotfix",_ "i386",_ "Intel",_ "Lexmark",_ "PerfLogs",_ "Recovery",_ "SYSTEM.SAV",_ "Xerox") For intInd = LBound(arrCarpRaiz) to UBound(arrCarpRaiz) If objFS.FolderExists(strUnidad & arrCarpRaiz(intInd)) Then RecorreCarpetas strUnidad & arrCarpRaiz(intInd), kCOMPLETA End If Next End Sub Sub Encabezado Dim strModo objArchLog.WriteLine(T_MSG_CHAR_1 & " " & kTITULO & " " & kVER & " - por NTurky " & T_MSG_CHAR_1) objArchLog.WriteLine(T_MSG_CHAR_1 & " " & T_MSG_E_IP & ": " & Date() & " - " & dtmTiempoInicio & " " & T_MSG_CHAR_1) objArchLog.WriteLine(kESPACIOS) objArchLog.WriteLine(T_MSG_E_N & ": " & strEquipo) objArchLog.WriteLine(T_MSG_E_U & ": " & objDisco.DriveLetter & " (" & objDisco.VolumeName & ")") objArchLog.WriteLine(T_MSG_E_C & ": " & Unidades(objDisco.TotalSize)) objArchLog.WriteLine(kESPACIOS) If kNO_UTILS Or kOFFLINE Then If kOFFLINE Then strModo = T_MSG_OFF Else strModo = T_MSG_NOU End If objArchLog.WriteLine(T_MSG_CHAR_1 & " " & strModo & " " & T_MSG_CHAR_1) objArchLog.WriteLine(kESPACIOS) End If End Sub Function EsAdmin Dim strClave EsAdmin = False On Error Resume Next strClave = objShell.RegRead("HKEY_USERS\S-1-5-19\Environment\TEMP") If Err.Number = 0 Then EsAdmin = True On Error Goto 0 End Function Function EstiloNum(intNro, intEsp) EstiloNum = String(intEsp-Len(intNro),"0") & intNro End Function Sub Finalizar objArchLog.WriteLine(T_MSG_F_ELI & ": " & Unidades(intEspLibIni)) objArchLog.WriteLine(T_MSG_F_ELF & ": " & Unidades(intEspLibFin)) objArchLog.WriteLine(T_MSG_F_EL & ": " & Unidades(intEsp)) objArchLog.WriteLine(kESPACIOS) objArchLog.WriteLine(T_MSG_E_IP & ": " & dtmTiempoInicio) objArchLog.WriteLine(T_MSG_F_FP & ": " & dtmTiempoFin) objArchLog.WriteLine(T_MSG_TE & ": " & strTiempoEmp) objArchLog.Close Set objArchLog = Nothing Set objFS = Nothing Set objDisco = Nothing Set objReg = Nothing End Sub Sub ModificaServicio (strServicio, booFinalizar) Dim intTimeOut : intTimeOut = 0 Dim strSalida, strAccion Dim objServicio Dim objCimv2 : Set objCimv2 = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ strEquipo & "\root\cimv2") Dim colServicios : Set colServicios = objCimv2.ExecQuery("Select * from Win32_Service Where Name='" & _ strServicio & "'") Dim intCant : intCant = colServicios.Count If intCant > 0 Then For Each objServicio in colServicios strSalida = T_MSG_SV & " " & UCase(objServicio.DisplayName) & " " If booFinalizar Then 'Detener servicio If objServicio.Started Then objServicio.StopService Do While objServicio.Started Set objServicio = objCimv2.Get("Win32_Service.Name='" & strServicio & "'") WScript.Sleep 100 intTimeOut = intTimeOut + 1 If intTimeOut > kTIMEOUT Then Salida strSalida & T_MSG_SV_ND Exit Sub End If Loop Else Salida strSalida & T_MSG_SV_ED Exit Sub End If strAccion = T_MSG_SV_D Else 'Iniciar servicio If Not objServicio.Started Then objServicio.StartService Do While Not objServicio.Started Set objServicio = objCimv2.Get("Win32_Service.Name='" & strServicio & "'") WScript.Sleep 100 intTimeOut = intTimeOut + 1 If intTimeOut > kTIMEOUT Then Salida strSalida & T_MSG_SV_NI Exit Sub End If Loop Else Salida strSalida & T_MSG_SV_EI Exit Sub End If strAccion = T_MSG_SV_I End If Salida strSalida & strAccion Next End If End Sub Sub ModoOffline Dim booSalgo : booSalgo = False Set objDisco = Nothing While Not booSalgo strUnidad = InputBox (T_MSG_MO_IN, kTITULO & " " & kVER, T_MSG_MO_INE) On Error Resume Next If objFS.DriveExists(strUnidad) Then Set objDisco = objFS.GetDrive(strUnidad) booSalgo = True strUnidad = objDisco.DriveLetter & ":\" Else objShell.Popup T_MSG_MO_ER, 2, kTITULO & " " & kVER, VBCritical End If Wend On Error Goto 0 If objFS.FolderExists(strUnidad & kXP_Documents_and_settings) Then strOS = "NT5" strUsuarios = strUnidad & kXP_Documents_and_settings End If If objFS.FolderExists(strUnidad & "Users") Then strOS = "NT" strUsuarios = strUnidad & "Users" End If End Sub Sub RecorreCarpetas(strCarpeta, booCompleta) Dim objC, objSC, objA If (objFS.FolderExists(strCarpeta)) Then On Error Resume Next Set objC = objFS.GetFolder(strCarpeta) 'recorre las subcarpetas For Each objSC in objC.SubFolders 'recursividad para subcarpetas RecorreCarpetas objSC.Path, kCOMPLETA Next 'recorre archivos de la carpeta raíz For Each objA in objC.Files dicArchivos.add intCArch, objA.Path intCArch = intCArch + 1 Next If booCompleta Then dicCarpetas.Add intCCarp, objC.Path intCCarp = intCCarp + 1 End If On Error Goto 0 Set objC = Nothing Set objSC = Nothing Set objA = Nothing End If End Sub Sub Salida (strLinea) If strLinea <> vbCrLf Then strLinea = EstiloNum(Hour(Time), 2) & ":" & EstiloNum(Minute(Time), 2) & ":" & EstiloNum(Second(Time), 2)_ & " - " & strLinea & "." End If objArchLog.WriteLine(strLinea) End Sub Function TiempoTranscurrido(dtmIni, dtmFin) Dim intTemp Dim intHoras, intMinutos, intSegundos intTemp = DateDiff("s", dtmIni, dtmFin) 'Hago esto para pasarlo a HH:MM:SS (string) intHoras = Int(intTemp/3600) intTemp = intTemp - (3600*intHoras) intMinutos = Int(intTemp/60) intSegundos = intTemp - (60*intMinutos) TiempoTranscurrido = EstiloNum(intHoras, 2) & ":" & EstiloNum(intMinutos, 2) & ":" & EstiloNum(intSegundos, 2) End Function Function Unidades(intEsp) Dim intUni, strUniNom If Abs(intEsp) >= kGBYTES Then intUni = kGBYTES strUniNom = T_MSG_GBYTES Elseif Abs(intEsp) >= kMBYTES Then intUni = kMBYTES strUniNom = T_MSG_MBYTES Elseif Abs(intEsp) >= kKBYTES Then intUni = kKBYTES strUniNom = T_MSG_KBYTES Else intUni = 1 strUniNom = T_MSG_BYTES End If Unidades = FormatNumber(intEsp/(intUni), kDECIMALES, , , kAGRUPAR) & " " & strUniNom End Function Sub UtilidadCleanmgr Dim strLog : strLog = strUnidad & "\Windows\Logs\CBS" Dim objCarpeta, objArchivo, strErr Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_C_INI dtmTiempoFin = Time intEsp = objDisco.FreeSpace CleanmgrFlag True On Error Resume Next Salida T_MSG_CHAR_3 & " " & T_MSG_EX & ".." strErr = objShell.Run("cleanmgr /d " & strUnidad & " /sagerun:" & kFLAG, kMOSTRAR, kESPERAR) If strErr = 0 Then Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_C & " " & T_MSG_TC Else Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_C & " " & T_MSG_TER Err.Clear End If CleanmgrFlag False If (objFS.FolderExists(strLog)) Then Salida T_MSG_SV_DS & ".." ModificaServicio "TrustedInstaller", kFINALIZAR Set objCarpeta = objFS.GetFolder(strLog) For Each objArchivo in objCarpeta.Files objArchivo.Delete(True) If Err.Number = 0 Then Salida objArchivo.Path & " - " & Unidades(objArchivo.Size) & " - " & T_MSG_EM Else Salida objArchivo.Path & " - " & Unidades(objArchivo.Size) & " - " & T_MSG_NPSM Err.Clear End If Next End If On Error Goto 0 Set objCarpeta = Nothing Set objArchivo = Nothing intEspLibFin = objDisco.FreeSpace - intEsp Salida T_MSG_CHAR_3 & " " & T_MSG_TE & " : " & TiempoTranscurrido(dtmTiempoFin, Time) Salida T_MSG_CHAR_3 & " " & T_MSG_EL & ": " & Unidades(intEspLibFin) Salida kESPACIOS End Sub Sub CleanmgrFlag(booCrear) Dim strClave : strClave = "Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\" Dim strFlag : strFlag = "StateFlags00" & kFLAG Dim arrClaReg, strClaReg On Error Resume Next objReg.EnumKey HKLM, strClave, arrClaReg For Each strClaReg in arrClaReg Select Case UCase(strClaReg) Case "OFFICE SETUP FILES" 'No quiero que los elimine Case "COMPRESS OLD FILES" 'No quiero que comprima (XP) Case "COMPRESS SYSTEM DISK" 'No quiero que comprima (W10) Case "USERS DOWNLOAD FOLDER" 'No quiero que borre "downloads" (W10) Case "DOWNLOADSFOLDER" 'No quiero que borre "downloads" (W10) Case Else If booCrear Then objReg.SetDWORDValue HKLM, strClave & strClaReg, strFlag, 2 Else objReg.DeleteValue HKLM, strClave & strClaReg, strFlag End If If kLOGEXTENDIDO Then If Err.Number = 0 Then If booCrear Then Salida T_MSG_OS & ": " & strClaReg Else Salida T_MSG_OR & ": " & strClaReg End If Else If booCrear Then Salida T_MSG_ERR_S & " " & strClaReg & ". " &_ T_MSG_ERR & ": " & Err.Number & " - " & Err.Description Else Salida T_MSG_ERR_R & " " & strClaReg & ". " &_ T_MSG_ERR & ": " & Err.Number & " - " & Err.Description End If Err.Clear End If End If End Select Next On Error Goto 0 End Sub Sub UtilidadDism Dim strErr Dim strLog : strLog = strUnidad & "\Windows\Logs\DISM\dism.log" Dim objArchivo Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_D_INI dtmTiempoFin = Time intEsp = objDisco.FreeSpace Salida T_MSG_CHAR_3 & " " & T_MSG_EX & ".." On Error Resume Next strErr = objShell.Run("dism.exe /online /cleanup-image /spsuperseded /hidesp", kOCULTAR, kESPERAR) If strErr = 0 Then Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_D & " " & T_MSG_TC Else Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_D & " " & T_MSG_TER Err.Clear End If If (objFS.FileExists(strLog)) Then Set objArchivo = objFS.GetFile(strLog) objArchivo.Delete(True) If Err.Number = 0 Then Salida objArchivo.Path & " - " & Unidades(objArchivo.Size) & " - " & T_MSG_EM Else Salida objArchivo.Path & " - " & Unidades(objArchivo.Size) & " - " & T_MSG_NPSM Err.Clear End If End If On Error Goto 0 Set objArchivo = Nothing intEspLibFin = objDisco.FreeSpace - intEsp Salida T_MSG_CHAR_3 & " " & T_MSG_TE & " : " & TiempoTranscurrido(dtmTiempoFin, Time) Salida T_MSG_CHAR_3 & " " & T_MSG_EL & ": " & Unidades(intEspLibFin) Salida kESPACIOS End Sub Sub UtilidadVssadmin Dim strErr Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_V_INI dtmTiempoFin = Time intEsp = objDisco.FreeSpace Salida T_MSG_CHAR_3 & " " & T_MSG_EX & ".." On Error Resume Next strErr = objShell.Run("vssadmin.exe Delete Shadows /For=" & objDisco.DriveLetter & ": /All /Quiet", kOCULTAR, kESPERAR) If strErr = 0 Then Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_V & " " & T_MSG_TC Else Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_V & " " & T_MSG_TER Err.Clear End If On Error Goto 0 intEspLibFin = objDisco.FreeSpace - intEsp Salida T_MSG_CHAR_3 & " " & T_MSG_TE & " : " & TiempoTranscurrido(dtmTiempoFin, Time) Salida T_MSG_CHAR_3 & " " & T_MSG_EL & ": " & Unidades(intEspLibFin) Salida kESPACIOS End Sub Sub UtilidadWevtutil Dim intInd : intInd = 0 Dim intContC : intContC = 0 Dim intContE : intContE = 0 Dim strErr Dim objCmd Dim dicLogs : Set dicLogs = CreateObject("Scripting.Dictionary") Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_W_INI dtmTiempoFin = Time On Error Resume Next Salida T_MSG_UTIL_W_CREA & ".." Set objCmd = objShell.Exec("cmd /c wevtutil el") Do While Not objCmd.StdOut.AtEndOfStream dicLogs.Add intInd, objCmd.StdOut.ReadLine() intInd = intInd + 1 Loop Salida dicLogs.Count & " " & T_MSG_UTIL_W_RS intEsp = objDisco.FreeSpace Salida T_MSG_CHAR_3 & " " & T_MSG_EX & ".." For intInd = 0 to dicLogs.Count - 1 strErr = objShell.Run("wevtutil cl " & dicLogs.Item(intInd), kOCULTAR, kESPERAR) If strErr = 0 Then If kLOGEXTENDIDO Then Salida EstiloNum(intInd + 1, Len(dicLogs.count)) & " - " & dicLogs.Item(intInd) & " - " & T_MSG_EM intContC = intContC + 1 Else If kLOGEXTENDIDO Then Salida EstiloNum(intInd + 1, Len(dicLogs.count)) & " - " & dicLogs.Item(intInd) & " - " & T_MSG_NPSM intContE = intContE + 1 Err.Clear End If Next On Error Goto 0 intEspLibFin = objDisco.FreeSpace - intEsp Salida T_MSG_UTIL_W_TR & " : " & dicLogs.Count Salida T_MSG_UTIL_W_RE & ": " & intContC Salida "(" & intContE & " " & T_MSG_UTIL_W_RER & ")" Salida T_MSG_CHAR_3 & " " & T_MSG_UTIL_W & " " & T_MSG_TC Salida T_MSG_CHAR_3 & " " & T_MSG_TE & " : " & TiempoTranscurrido(dtmTiempoFin, Time) Salida T_MSG_CHAR_3 & " " & T_MSG_EL & ": " & Unidades(intEspLibFin) Salida kESPACIOS Set dicLogs = Nothing End Sub