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

PowerShell: Create SMB Share and Grant NTFS Access

$localPath="C:\testShare" $fullAccessAccounts='everyone','authenticated users' function createSmbShare($localPath,$fullAccessAccounts){ $ErrorActionPreference='stop' try{ # First, create SMB Share $smbShareName=split-path $localPath -leaf…

PowerShell: Check VLAN of Windows Machine

Le Kommand: Get-NetAdapter|select Name,VlanID Sample Outputs PS C:\Windows\system32> Get-NetAdapter|select Name,VlanIDName VlanID---- ------Ethernet 1 0 PS…

PowerShell: Take VM Snapshots

# takeVmSnapshot.ps1 $vmNames='Test-VM1','Cowabunga-VM4' $snapShotLabel="Snapshot $(get-date -Format yyyyMMddTHHmmss)" function takeVmSnapshot([string[]]$vmName,[string]$snapshotLabel){ $vmClusterNodes=Get-ClusterGroup|?{$_.GroupType -eq 'VirtualMachine'} foreach ($vm in…