-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize temporary file storage and separate cleanup activities
- Loading branch information
1 parent
20d0451
commit 61e2047
Showing
9 changed files
with
111 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
################################################################################ | ||
## File: Invoke-Cleanup.ps1 | ||
## Desc: Cleanup WinSxS, temp, cache and compress some directories | ||
################################################################################ | ||
|
||
Write-Host "Cleanup WinSxS" | ||
dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to cleanup WinSxS" | ||
} | ||
|
||
Write-Host "Clean up various directories" | ||
@( | ||
"$env:SystemDrive\Recovery", | ||
"$env:SystemRoot\logs", | ||
"$env:SystemRoot\winsxs\manifestcache", | ||
"$env:SystemRoot\Temp", | ||
"$env:SystemRoot\Installer", | ||
"$env:SystemDrive\Users\$env:INSTALL_USER\AppData\Local\Temp", | ||
"$env:TEMP", | ||
"$env:AZURE_CONFIG_DIR\logs", | ||
"$env:AZURE_CONFIG_DIR\commands", | ||
"$env:AZURE_CONFIG_DIR\telemetry" | ||
) | ForEach-Object { | ||
if (Test-Path $_) { | ||
Write-Host "Removing $_" | ||
cmd /c "takeown /d Y /R /f $_ 2>&1" | Out-Null | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to take ownership of $_" | ||
} | ||
cmd /c "icacls $_ /grant:r administrators:f /t /c /q 2>&1" | Out-Null | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to grant administrators full control of $_" | ||
} | ||
Remove-Item $_ -Recurse -Force -ErrorAction SilentlyContinue | Out-Null | ||
} | ||
} | ||
|
||
# Remove AllUsersAllHosts profile | ||
Remove-Item $profile.AllUsersAllHosts -Force -ErrorAction SilentlyContinue | Out-Null | ||
|
||
# Clean yarn and npm cache | ||
cmd /c "yarn cache clean 2>&1" | Out-Null | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to clean yarn cache" | ||
} | ||
|
||
cmd /c "npm cache clean --force 2>&1" | Out-Null | ||
if ($LASTEXITCODE -ne 0) { | ||
throw "Failed to clean npm cache" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.