Friday, January 29, 2021

Powershell Script to start and clean Google Chrome

   # Run before opening Chrome

#  get Chrome Process 

if ((Get-Process "chrome" -ErrorAction SilentlyContinue) -eq $Null)  {
    echo "Google Chrome Not Running"
}

else{
    echo "Running"
    taskkill /f /IM "chrome.exe"
    Sleep 3
}

start-Sleep -Seconds 5

echo ""
echo "******************************************"
echo "*Clearing Cache, Credentials & Login Data*"
echo "******************************************"

$Items = @('Cache\*',
           'Cookies',
           'Login Data')
$Folder = "$($env:LOCALAPPDATA)\Google\Chrome\User Data\Default"
$Items | % {
    if (Test-Path "$Folder\$_") {
        ls "$Folder\$_"
        Remove-Item "$Folder\$_"
    }
} 
echo ""
echo "***************************"
echo "*Poweshell Script Complete*"
echo "*Starting Google Chrome   *"
echo "***************************"
echo ""

#$FolderC ="$($env:LOCALAPPDATA)\Google\Chrome\Application"
cd 'C:\Program Files\Google\Chrome\Application' 
#& ./chrome.exe 'www.google.com'
#Test-Path "$FolderC"
.\chrome.exe

No comments:

Post a Comment

Gammon => Ham Calculator V1.0

def ham_cooking_time (grams): """ Calculates the cooking time for a ham based on its weight. Args: g...