Posted On June 11, 2022

PowerShell: Change Google Chrome Cache Directory

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Change Google Chrome Cache Directory

Lately, I’ve been running a buck load of chrome tabs that utilize all available I/O disk speed that my default C:\ volume could keep up. Thus, Chrome often lags to the point of being annoying or unusable. Here are two methods to move the Default Chrome directory toward a different volume to improve Chrome’s performance:

# Method 1: Move the whole Chrome Default profile's storage directory
$profilePath="C:\Users\$env:username\AppData\Local\Google\Chrome\User Data\Default"
$newPath='D:\chrome\Default'

robocopy "$profilePath" "$newPath" /mir /xj /copyall
ren $profilePath "$profilePath`_old"
& mklink $profilePath $newPath /j
cmd /c mklink /d $profilePath $newPath

# Method 2: Move only Chrome Cache
$newCacheDirectory="D:\chromeCache\$env:username"
function changeChromeCacheDirectory{
    param(
      $newCacheDirectory="D:\chromeCache\$env:username",
      $defaultCacheDirectory="C:\Users\$env:username\AppData\Local\Google\Chrome\User Data\Default\Cache"
    )
    try{
        Stop-Process -Name chrome
        mkdir $newCacheDirectory
        rmdir $defaultCacheDirectory -force -Recurse
        New-Item -ItemType Junction -Path $defaultCacheDirectory -Target $newCacheDirectory
        write-host "Chrome cache directory has been changed`r`nFrom: $defaultCacheDirectory`r`nTo: $newCacheDirectory" -ForegroundColor Green
        return $true
    }catch{
        write-warning $_
        return $false
    }
}

changeChromeCacheDirectory $newCacheDirectory

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Basic CSS: Size Your Images

<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css"><style>.red-text {color: red;}h2 {font-family: Lobster, monospace;}p {font-size: 16px;font-family: monospace;}</style><h2 class="red-text">CatPhotoApp</h2><main><p class="red-text">Click here…

PowerShell: Hyper-V Management

Migrate Live Virtual Machines (In Clustered Environment): # Connect to Hyper-V Host$remoteHost="HYPERV01"Enter-PsSession $remoteHost # Move…

PowerShell: Backup, Archive, and Remove a Microsoft SQL Database

$sqlServer='sqlsherver007' $databaseName="someDatabaseName" $saCredential=get-credential $backupDestination="\\Archive03\MSSQL_Backups" function triggerSqlBackup($sqlServer,$databaseName){ # Ensure the the Jump Box has SQL PowerShell…