Google Chrome Cache/Cookies Clear

Hello again, all!

I have a request from an end user that is looking to have an option in their Software Center to clear their cache and cookies. I drummed up a pretty basic Deploy-Application. I have the pre-installation task creating a registry key (for detection purposes) and also closing out Chrome. In the installation section, I tell it to do the following:

Remove-File -Path "$envUserProfile\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies" -recurse
Remove-File -Path "$envUserProfile\AppData\Local\Google\Chrome\User Data\Default\Network\Cookies-journal" -recurse
Remove-Folder -Path "$envUserProfile\AppData\Local\Google\Chrome\User Data\Default\Cache" -recurse
Start-Sleep -Seconds 15
Execute-Process -Path "C:\Program Files\Google\Chrome\Application\chrome.exe" 

The uninstall would simply be the removal of the registry key so that the end users can run the cleaner again in the future if need be.

With that being said, when I attempt to run the install through Software Center, I get the UAC prompt asking for admin credentials.

Maybe I am overlooking something stupid, but any insight would help!

Thanks in advance as always!

Check your log file.
I suspect $envUserProfile is one of your system profiles (you have two: 32 bit and 64 bit)

BTW: I did something similar but I launch it as a SCCM package so that I wouldn’t need a reg key or tag file for the SCCM App to “Detect”.

Hello again, sir.

Thanks for the response. I just reviewed all the PSADT variables that are available and if $envUserProfile is not working (possibly due to the system account), which variable do you think I should possibly try in that case? I saw one that would affect all profile users, but I would prefer to try and keep this solely for the current signed in user.

Thanks!

Side note, I am checking a colleague of mine’s script for a Teams cache removal and he is using the same variable as I am. His script works fine with no issues and does not prompt for UAC.

compare the SCCM app settings.
specifically the deployment types

Compared the deployment types, they’re identical. =\

Copy his SCCM app and change as little as possible to make your script work.
If it doesn’t work, it’s your script.

As That-Annoying-Guy wrote, the problem could be that in your case the $envUserProfile variable points to the system profile, not the profile of the user sitting in front of the computer. You may be able to solve the problem by running the script in the user’s context, not the local system context. You must configure this in the deployment’s “User Experience” settings within the Config Manager application. Note that you will then no longer be able to use the PSAppDeployment toolkit as, to my knowledge, Deploy-Application.exe needs admin privileges to run. You could instead run a simple command line batch file that deletes the folders and creates the detection registry key. In this case, this registry key must be in HKCU, not in HKLM.
26-04-_2022_10-17-12

1 Like

Thanks for the response. Took the last part of your advice and made the Set-RegistryKey under the HKCU and not HKLM.

I ended up make a duplicate of my co-worker’s script and then removed/inserted what was needed. I wasn’t going to spend the time tearing it apart to see if there was a typo somewhere, but now the issue is resolved and the script works!

Thanks again, all!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.