Permalink
Switch branches/tags
Nothing to show
Find file Copy path
568 lines (500 sloc) 39.8 KB
<job id="Action-CleanupBeforeSysprep">
<script language="VBScript" src="..\..\Scripts\ZTIUtility.vbs"/>
<script language="VBScript">
'//----------------------------------------------------------------------------
'// Solution: RefImage Creation
'// Purpose: Used to remove files and folders before sysprep
'// Usage: cscript Action-CleanupBeforeSysprep.wsf [/debug:true]
'// Version: 2.0 - Dec 9 2015
'// Version: 2.1 - Dec 14 2015
'// Version: 2.2 - Dec 28 2015
'// Version: 2.3 - Jan 24 2016
'// Version: 2.4 - Feb 8 2016
'// Version: 2.5 - Nov 11 2016 - Moved the DISM section /Resetbase for 10. Minor updates in remarks and text
'// Mikael Nystrom & Johan Arwidmark
'// This script is provided "AS IS" with no warranties, confers no rights and
'// is not supported by the authors, Deployment Bunny or Deployment Artists.
'//
'//----------------------------------------------------------------------------
'// Revision History
'// Version 2.3: Added a repair step, since many patched will "break" the component store
'// Version 2.4: Added a Patch Folder cleanup, it will now remove all downloaded patches from the cache.
'//----------------------------------------------------------------------------
'// Global constant and variable declarations
'//----------------------------------------------------------------------------
Option Explicit
Dim iRetVal
'//----------------------------------------------------------------------------
'// End declarations
'//----------------------------------------------------------------------------
'//----------------------------------------------------------------------------
'// Main routine
'//----------------------------------------------------------------------------
'On Error Resume Next
iRetVal = ZTIProcess
ProcessResults iRetVal
On Error Goto 0
'//---------------------------------------------------------------------------
'//
'// Function: ZTIProcess()
'//
'// Input: None
'//
'// Return: Success - 0
'// Failure - non-zero
'//
'// Purpose: Perform main ZTI processing
'//
'//---------------------------------------------------------------------------
Function ZTIProcess()
Dim sActionName
Dim sOSCurrentVersion
Dim sOSCurrentVersionShort
Dim sIsServerOS
Dim sExe
Dim sFolder
sActionName = "Action-CleanupBeforeSysprep"
sOSCurrentVersion = oEnvironment.item("OSCurrentVersion")
sIsServerOS = oEnvironment.item("IsServerOS")
sOSCurrentVersionShort = Left(oEnvironment.item("OSCurrentVersion"),3)
'Starting
oLogging.CreateEntry sActionName & ": Starting", LogTypeInfo
Select Case sIsServerOS
Case "False"
'Client OS
oLogging.CreateEntry sActionName & ": Running on Client OS", LogTypeInfo
Select Case sOSCurrentVersionShort
Case "6.1"
' Windows 7 SP1
oLogging.CreateEntry sActionName & ": Running on Windows 7 SP1", LogTypeInfo
'Add sagerun:5432 to registy
oLogging.CreateEntry sActionName & ": Adding reg values for CleanMgr", LogTypeInfo
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Content Indexer Cleaner\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Device Driver Packages\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Sync Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows ESD installation files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files\StateFlags5432", "00000002", "REG_DWORD"
'Execute CleanMgr.exe
oLogging.CreateEntry sActionName & ": Running CleanMgr", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("CleanMgr.exe /sagerun:5432")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Cleaning up the SoftwareDistribution folder
oLogging.CreateEntry sActionName & ": Cleaning up the SoftwareDistribution folder", LogTypeInfo
oUtility.RunWithConsoleLogging("net.exe stop wuauserv")
oUtility.RunWithConsoleLogging("cmd.exe /c del c:\windows\SoftwareDistribution /q /s")
oUtility.RunWithConsoleLogging("net.exe start wuauserv")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished", LogTypeInfo
Case "6.2"
' Windows 8
oLogging.CreateEntry sActionName & ": Running on Windows 8", LogTypeInfo
'Add sagerun:5432 to registy
oLogging.CreateEntry sActionName & ": Adding reg values for CleanMgr", LogTypeInfo
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest\OSD", "Done", "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Content Indexer Cleaner\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Device Driver Packages\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Sync Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows ESD installation files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files\StateFlags5432", "00000002", "REG_DWORD"
'Execute DISM.exe /online /Cleanup-Image /RestoreHealth
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /RestoreHealth", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /RestoreHealth")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Execute DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Execute CleanMgr.exe
oLogging.CreateEntry sActionName & ": Running CleanMgr", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("CleanMgr.exe /sagerun:5432")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Cleaning up the SoftwareDistribution folder
oLogging.CreateEntry sActionName & ": Cleaning up the SoftwareDistribution folder", LogTypeInfo
oUtility.RunWithConsoleLogging("net.exe stop wuauserv")
oUtility.RunWithConsoleLogging("cmd.exe /c del c:\windows\SoftwareDistribution /q /s")
oUtility.RunWithConsoleLogging("net.exe start wuauserv")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished", LogTypeInfo
Case "6.3"
' Windows 8.1
oLogging.CreateEntry sActionName & ": Running on Windows 8.1", LogTypeInfo
'Add sagerun:5432 to registy
oLogging.CreateEntry sActionName & ": Adding reg values for CleanMgr", LogTypeInfo
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\User file versions\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows ESD installation files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files\StateFlags5432", "00000002", "REG_DWORD"
'Execute DISM.exe /online /Cleanup-Image /RestoreHealth
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /RestoreHealth", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /RestoreHealth")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Execute DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Execute CleanMgr.exe
oLogging.CreateEntry sActionName & ": Running CleanMgr", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("CleanMgr.exe /sagerun:5432")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Cleaning up the SoftwareDistribution folder
oLogging.CreateEntry sActionName & ": Cleaning up the SoftwareDistribution folder", LogTypeInfo
oUtility.RunWithConsoleLogging("net.exe stop wuauserv")
oUtility.RunWithConsoleLogging("cmd.exe /c del c:\windows\SoftwareDistribution /q /s")
oUtility.RunWithConsoleLogging("net.exe start wuauserv")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished", LogTypeInfo
' Windows 10
Case "10."
oLogging.CreateEntry sActionName & ": Running on Windows 10", LogTypeInfo
'Add sagerun:5432 to registy
oLogging.CreateEntry sActionName & ": Adding reg values for CleanMgr", LogTypeInfo
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest\OSD", "Done", "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Content Indexer Cleaner\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Device Driver Packages\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Delivery Optimization Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\RetailDemo Offline Content\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Sync Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows ESD installation files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Defender\StateFlags5432", "00000002", "REG_DWORD"
'Execute DISM.exe /online /Cleanup-Image /RestoreHealth
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /RestoreHealth", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /RestoreHealth")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Execute CleanMgr.exe /sagerun:5432
oLogging.CreateEntry sActionName & ": Running CleanMgr.exe /sagerun:5432", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("CleanMgr.exe /sagerun:5432")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Cleaning up the SoftwareDistribution folder
oLogging.CreateEntry sActionName & ": Cleaning up the SoftwareDistribution folder", LogTypeInfo
oUtility.RunWithConsoleLogging("net.exe stop wuauserv")
oUtility.RunWithConsoleLogging("cmd.exe /c del c:\windows\SoftwareDistribution /q /s")
oUtility.RunWithConsoleLogging("net.exe start wuauserv")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished", LogTypeInfo
'Execute DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
End Select
Case "True"
'Server OS
oLogging.CreateEntry sActionName & ": Running on Server OS", LogTypeInfo
Select Case sOSCurrentVersionShort
Case "6.1"
' Windows Server 2008 R2 SP1
oLogging.CreateEntry sActionName & ": Running on Windows Server 2008 R2", LogTypeInfo
'Copy cleanmgr.exe to System32
oLogging.CreateEntry sActionName & ": Copying cleanmgr.exe", LogTypeInfo
sExe = "C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe"
sFolder = "C:\Windows\System32\"
If not oFSO.FileExists(sExe) then
oLogging.CreateEntry sActionName & ": " & sExe & " was not found, unable to continue", LogTypeInfo
ZTIProcess = Failure
Exit Function
End if
oLogging.CreateEntry sActionName & ": Copy " & sExe & " To " & sFolder, LogTypeInfo
oFSO.GetFile(sExe).Copy sFolder & oFSO.GetFileName(sExe),True
'Copy cleanmgr.exe.mui
oLogging.CreateEntry sActionName & ": Copying CleanMgr MUI", LogTypeInfo
sExe = "C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui"
sFolder = "C:\Windows\System32\en-US\"
If not oFSO.FileExists(sExe) then
oLogging.CreateEntry sActionName & ": " & sExe & " was not found, unable to continue", LogTypeInfo
ZTIProcess = Failure
Exit Function
End if
oLogging.CreateEntry sActionName & ": Copy " & sExe & " To " & sFolder, LogTypeInfo
oFSO.GetFile(sExe).Copy sFolder & oFSO.GetFileName(sExe),True
'Add sagerun:5432 to registy
oLogging.CreateEntry sActionName & ": Adding reg values for CleanMgr", LogTypeInfo
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Content Indexer Cleaner\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Device Driver Packages\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Offline Pages Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Service Pack Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Sync Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Update Cleanup\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows ESD installation files\StateFlags5432", "00000002", "REG_DWORD"
oShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Upgrade Log Files\StateFlags5432", "00000002", "REG_DWORD"
'Execute CleanMgr.exe
oLogging.CreateEntry sActionName & ": Running CleanMgr", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("CleanMgr.exe /sagerun:5432")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Cleaning up the SoftwareDistribution folder
oLogging.CreateEntry sActionName & ": Cleaning up the SoftwareDistribution folder", LogTypeInfo
oUtility.RunWithConsoleLogging("net.exe stop wuauserv")
oUtility.RunWithConsoleLogging("cmd.exe /c del c:\windows\SoftwareDistribution /q /s")
oUtility.RunWithConsoleLogging("net.exe start wuauserv")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished", LogTypeInfo
Case "6.2"
' Windows Server 2012
oLogging.CreateEntry sActionName & ": Running on Windows Server 2012", LogTypeInfo
'Execute DISM.exe /online /Cleanup-Image /RestoreHealth
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /RestoreHealth", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /RestoreHealth")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Execute DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /StartComponentCleanup", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /StartComponentCleanup")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Cleaning up the SoftwareDistribution folder
oLogging.CreateEntry sActionName & ": Cleaning up the SoftwareDistribution folder", LogTypeInfo
oUtility.RunWithConsoleLogging("net.exe stop wuauserv")
oUtility.RunWithConsoleLogging("cmd.exe /c del c:\windows\SoftwareDistribution /q /s")
oUtility.RunWithConsoleLogging("net.exe start wuauserv")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished", LogTypeInfo
Case "6.3"
' Windows Server 2012 R2
oLogging.CreateEntry sActionName & ": Running on Windows Server 2012 R2", LogTypeInfo
'Execute DISM.exe /online /Cleanup-Image /RestoreHealth
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /RestoreHealth", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /RestoreHealth")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Execute DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Cleaning up the SoftwareDistribution folder
oLogging.CreateEntry sActionName & ": Cleaning up the SoftwareDistribution folder", LogTypeInfo
oUtility.RunWithConsoleLogging("net.exe stop wuauserv")
oUtility.RunWithConsoleLogging("cmd.exe /c del c:\windows\SoftwareDistribution /q /s")
oUtility.RunWithConsoleLogging("net.exe start wuauserv")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished", LogTypeInfo
Case "10."
' Windows Server 2016
oLogging.CreateEntry sActionName & ": Running on Windows Server 2016", LogTypeInfo
'Execute DISM.exe /online /Cleanup-Image /RestoreHealth
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /RestoreHealth", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /RestoreHealth")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
'Cleaning up the SoftwareDistribution folder
oLogging.CreateEntry sActionName & ": Cleaning up the SoftwareDistribution folder", LogTypeInfo
oUtility.RunWithConsoleLogging("net.exe stop wuauserv")
oUtility.RunWithConsoleLogging("cmd.exe /c del c:\windows\SoftwareDistribution /q /s")
oUtility.RunWithConsoleLogging("net.exe start wuauserv")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
oLogging.CreateEntry oUtility.ScriptName & ": Finished", LogTypeInfo
'Execute DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
oLogging.CreateEntry sActionName & ": Running DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase", LogTypeInfo
iRetVal = oUtility.RunWithConsoleLogging("DISM.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase")
oLogging.CreateEntry sActionName & ": Done", LogTypeInfo
if (iRetVal = 0) or (iRetVal = 3010) then
ZTIProcess = Success
Else
ZTIProcess = Failure
Exit Function
End If
End Select
Case Else
'Unknown
oLogging.CreateEntry sActionName & ": Running on unknown OS type", LogTypeInfo
End Select
End Function
</script>
</job>