Cleanup & Disable Offline Files

Modified on Thu, 31 Jul at 11:38 AM

Run in Admin PowerShell:

# Disable Offline Files
Invoke-Command -ScriptBlock {
    Start-Process -FilePath "cmd.exe" -ArgumentList "/c sc config cscservice start= disabled" -Verb RunAs
    Start-Process -FilePath "cmd.exe" -ArgumentList "/c sc stop cscservice" -Verb RunAs
}

# Clear CSC Cache on next reboot
Invoke-Command -ScriptBlock {
    New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\CSC\Parameters" -Name "FormatDatabase" -Value 1 -PropertyType DWord -Force
}

# Take ownership and grant permissions to Administrators
$folderPath = "C:\Windows\CSC"

# Take ownership
takeown /f $folderPath /r /d Y

# Grant full control to Administrators group
icacls $folderPath /grant "Administrators:F" /t /c

# Delete folder
Remove-Item -Path $folderPath -Recurse -Force

The last line, the deleting of the old files might not work and might need a restart first.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article