VMware Workspace ONE Community
FalzonJ
Contributor
Contributor

Trying to deploy a Batch Script

Hello,  1st time poster.

 

I am trying to deploy a batch file using the provisioning aspect of the Workspace One UEM.

when i deploy the batch file using the "systems' context the batch script to clear both Edge (chromium) browser and Google Chrome Browser does close both browsers but when it runs the command within the batch to clear the browser cache it does not do this.

Running the batch manually does clear the cached files. I am lost as to why one aspect of the batch script runs but does not run the rest of the script.

context of script is below: 

taskkill /F /IM "chrome.exe">nul 2>&1


set ChromeDir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default\Cache\Cache_Data

del /q /s /f "%ChromeDir%"
rd /s /q "%ChromeDir%"

exit

 

 

Reply
0 Kudos
3 Replies
ogushia
Hot Shot
Hot Shot

I think that variable %USERNAME% in the "set ChromeDir ..." line is assigned "SYSTEM" when using "system" as user context.

So I think the batch tries to delete C:\Users\SYSTEM\AppData\Local\Google\Chrome\User Data\Default\Cache\Cache_Data and so the path corresponding to the real user is not deleted.

FalzonJ
Contributor
Contributor

this makes a lot of sense now that you put it that way.

The only issue is if I user Current User as the context so the script acts on the correct folder is that the powershell script fails. 

On the administrator Context it prompts UAC and admin username and password (which our users don't have)

Is there a way to make an argument to allow this to go through?

Reply
0 Kudos
Afshin_Lak
Enthusiast
Enthusiast

Can you try this one? Works in my lab. No Admin rights needed. Works for current user.

Afshin_Lak_0-1676900738692.png

Afshin_Lak_1-1676900801495.png

Afshin_Lak_2-1676900865994.png

Afshin_Lak_3-1676900927249.png

Remove-Item -path "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Cache\*" -Recurse -Force -EA SilentlyContinue -Verbose (NOT Copy/Paste this but write it again in Powershell)

Afshin_Lak_4-1676901026867.png

Afshin_Lak_5-1676901061969.png

Afshin_Lak_6-1676901123855.png

Afshin_Lak_7-1676901162209.png

Afshin_Lak_8-1676901195902.png

 

Reply
0 Kudos