Logoff Script To Wipe Cache Data Not Working In Citrix PvD

We have a XenDesktop 7.5 environment that uses PvD and UPM.

We are trying to conserve space on each person's PvD so we don't have to manually reset it as often. Currently, the PvDs are getting full too often. Our current attempt is to wipe Google Earth cache data on logoff since that uses up quite a bit of space.

Here is our current script:
@echo off
if %os%==Windows_NT goto WINNT
goto NOCON

:WINNT
echo .Using a Windows NT based system
echo ..%computername%

echo Delete Google Earth Cache
del /q /f /s "%USERPROFILE%\AppData\LocalLow\Google\GoogleEarth\webdata
del /q /f /s "%USERPROFILE%\AppData\LocalLow\Google\GoogleEarth\unified_cache_leveldb_leveldb2
echo deleted!

goto END

:NOCON
echo Error...Invalid Operating System...
echo Error...No actions were made...
goto END

:END

Open in new window


The GPO is working, but we aren't seeing the cached data getting wiped, and I think I know why.
When going to the PvD of my test VM, I can see that Citrix is setting two profiles for the user.
PvD makes two profiles for the user
My understanding is that since the LocalLow folder (where Google Earth cache is stored) isn't handled by UPM, that the LocalLow will stay with the PvD on the local machine.

I think the script is looking in the "testuser.domain" folder and not in the "testuser" folder since the %USERPROFILE% that is logged in the "testuser.domain" account.

How can I get the script to wipe the webdata and unified_cache_leveldb_leveldb2 folders?
LVL 5
Paul WagnerFriend To Robots and RocksAsked:
Who is Participating?
 
Spike99On-Site IT TechnicianCommented:
The variable %userprofile% generally points to the User's profile folder on the C: drive (%userprofile% points to C:\users\%USERNAME%, usually).

If you log on as that user & type "%userprofile% in Window explorer, does it take you to the C: drive location or to the PvD location?

If that takes you anywhere else other than the network location for the PvD in question, I would change the script to use the user name variable (%USERNAME%) instead of the user profile variable (%USERPROFILE%).

So, assuming the server location for the user's PvD is \\FILESERVER\PvD$\%username%, try changing those lines to this:
del /q /f /s \\FILESERVER\PvD$\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\webdata
del /q /f /s \\FILESERVER\PvD$\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\unified_cache_leveldb_le

del /q /f /s \\FILESERVER\PvD$\%USERNAME%.DOMAIN\AppData\LocalLow\Google\GoogleEarth\webdata
del /q /f /s \\FILESERVER\PvD$\%USERNAME%.DOMAIN\AppData\LocalLow\Google\GoogleEarth\unified_cache_leveldb_le

Open in new window

0
 
McKnifeCommented:
Why don't you run it manually, for a start? For example, you could use Chrome's "open file" menu to navigate to cmd.exe, and start a cmd where you can examine, what the deletion commands do/don't do.
Press CTRL-O in chrome, navigate to C:\Windows\System32\cmd.exe, right click it and select "open". Now launch your commands.

Also, make sure that your script runs at all by adding a line
md %userprofile%\test
to set a marker.

And close those " at the end of your del-commands (although it does not matter, here, since there are no blanks).
0
 
Paul WagnerFriend To Robots and RocksAuthor Commented:
What's the difference in launching a cmd from the start menu vs. doing it in chrome? Just a different way of accessing the cmd?

Now launch your commands.
I assume you mean to launch them in the .bat file.
I launched it and it said the system could not find the path specified.

The test folder was created in the "testuser.domain" folder. It looks like the "testuser" folder is only there to store LocalLow information.

Oh! I didn't catch the quotes. Thanks for mentioning that.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
McKnifeCommented:
The difference: I thought, you would not even have a full session in front of you so that was the only way to access cmd - I was wrong, obviously. You know, some remote desktop solutions don't offer full sessions.

About your problem: I guess it is something easy: your user has 2 profiles, an old one and a current one. The current one is c:\users\testuser.domain. And in that folder, there is no such path that you are trying to delete files in. Or is there a folder c:\users\testuser.domain\AppData\LocalLow\Google\GoogleEarth\webdata ?

What you might not know: when we try to delete test user by removing his user object in local account management, his profile folder is not removed. So when we reinstate that username a 2nd time, the new profile folder won't be the same (c:\username), but instead c:\username.domain - I guess that is what has happened here. You have a new profile, the new profile has no google earth data yet - nothing to delete. You are looking at the wrong profile folder.
0
 
Paul WagnerFriend To Robots and RocksAuthor Commented:
@McKnife
your user has 2 profiles, an old one and a current one.
Not quite. The "testuser" folder only has the LocalLow folder and the "testuser.domain" folder has Local and Roaming. This is the case regardless of how many times I logon/logoff or delete the folders. After talking to a UPM engineer, I realize this behavior is because LocalLow is not handled by UPM, so it makes another folder.


@Spike99
If you log on as that user & type "%userprofile% in Window explorer, does it take you to the C: drive location or to the PvD location?
Going to %userprofile% will take me to the list of folders for the user (desktop, downloads, etc.) but they are all redirects linked to a file server.
With that said, going to "%userprofile%\appdata" will take me to the PvD.

I love the idea to your script, but there's a problem. The PvD isn't stored on a "\\FILESERVER". It is stored with the VM itself, so I used %computername%?

So, it would look this?:
del /q /f /s "\\%computername%\p$\Users\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\webdata"

There's a problem with "%USERNAME%.DOMAIN". I can't navigate to it in explorer.
I found that to get to the testuser.domain profile, I actually need to use %USERPROFILE%.
... BUT, that doesn't really matter because LocalLow and Google Earth cache isn't stored in "testuser.domain", so we don't even need those entries. I made a modified entry for it in case it ever weirdly decided to show up there.

So, with all of that said, here's what I have:
@echo off
if %os%==Windows_NT goto WINNT
goto NOCON

:WINNT
echo .Using a Windows NT based system
echo ..%computername%

echo Delete Google Earth Cache
del /q /f /s "\\%computername%\p$\Users\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\webdata"
del /q /f /s "\\%computername%\p$\Users\%USERNAME%\AppData\LocalLow\Google\GoogleEarth\unified_cache_leveldb_leveldb2"
del /q /f /s "\\%computername%\p$\Users\%USERPROFILE%\AppData\LocalLow\Google"
echo deleted!

goto END

:NOCON
echo Error...Invalid Operating System...
echo Error...No actions were made...
goto END

:END

Open in new window

0
 
McKnifeCommented:
Whatever you say. But if there is a folder
%USERPROFILE%\AppData\LocalLow\Google\GoogleEarth\webdata present, then a del command would work. The script does not work any different to just logging on as user and open a command shell and execute the del commands manually. If those fail (path not found), then there is no doubt: this user does not have that folder.
0
 
Spike99On-Site IT TechnicianCommented:
Did that revised script work as you would like it to?
0
 
Paul WagnerFriend To Robots and RocksAuthor Commented:
Yes, the script is working, but I think the issue is that LocalLow is not redirected via UPM with Local and Roaming. Because of this fact, I believe the parameters are not ideal: the profile is splintered.

I am going to keep this script and find a way to redirect LocalLow into UPM so that the entire profile is in one folder. If that happens, I can then worry about one folder instead of two.

Thank you both for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.