Avatar of Noah Williams
Noah Williams
 asked on

Write Script to Remove Temporary Internet Files and RDP junk files from Citrix 4.5 App Server

I need assistance writing a script that will remove temporary internet files, RDP junk data and any other superfluous profile data from a Cittrix XenApp 4.5 Application server on a daily basis. The server is running out of disk space on the primary system partition (less than 1GB) because of about 100 user profiles and their associated data... Please assist. Thank you for your expertise!
ProgrammingCitrixVB Script

Avatar of undefined
Last Comment
Noah Williams

8/22/2022 - Mon
VishavSingh

Below script will delete Temporary internet files, History and cookies. Save the below script in (xxxx.bat) and run on the server. Please test the script before running on production servers:-

SET drive=%SYSTEMDRIVE%
SET SRC1=%drive%\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files
SET SRC3=Local Settings\History
SET SRC5=Cookies
@echo.
@echo.
@echo About to delete Temporary Internet Files
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
@echo.
@echo About to delete History
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
@echo About to delete Cookies
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC5%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC5%\*.*") DO DEL /F /S /Q "%%Y"
@echo.
CD\
goto end
:end
cls
Noah Williams

ASKER
Will this effect all user profiles at once or will I need to run it per user profile?

Thanks,
nw
VishavSingh

It will effect all user profiles
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Noah Williams

ASKER
OK, I will test and get back to you very shortly.

Thank you!
Noah Williams

ASKER
Get the following error...

Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

X:\>SET drive=%SYSTEMDRIVE%

X:\>SET SRC1=%drive%\Documents and Settings

X:\>SET SRC2=Local Settings\Temporary Internet Files

X:\>SET SRC3=Local Settings\History

X:\>SET SRC5=Cookies

X:\>@echo.


X:\>@echo.


X:\>@echo About to delete Temporary Internet Files
About to delete Temporary Internet Files

X:\>
X:\>FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /
Q "%%Y"
%%X was unexpected at this time.
X:\>
VishavSingh

Did you run the code after copying in .bat file ?  I just tried the same code. it's working on windows 2003 server.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Noah Williams

ASKER
I modified it and ran it as a .bat and it ran. Please let m eknow what you think of the modification.

Thank you!

SET drive=%SYSTEMDRIVE%
SET SRC1=%drive%\Documents and Settings
SET SRC2=Local Settings\Temporary Internet Files
SET SRC3=Local Settings\History
SET SRC5=Cookies
SET SRC6=Local Settings\Temp
@echo.
@echo.
@echo About to delete Temporary Internet Files
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
@echo.
@echo About to delete History
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC3%\*.*") DO RMDIR /S /Q "%%Y"
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC3%\*.*") DO DEL /F /S /Q "%%Y"
@echo About to delete Cookies
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC5%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC5%\*.*") DO DEL /F /S /Q "%%Y"
@echo.
@echo About to delete Temp
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC6%\*.*") DO RMDIR /S /Q "%%Y"
@echo.
FOR /D %%X IN ("%SRC1%\*") DO FOR %%Y IN ("%%X\%SRC6%\*.*") DO DEL /F /S /Q "%%Y"
@echo.
CD\
goto end
:end
cls
ASKER CERTIFIED SOLUTION
VishavSingh

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Noah Williams

ASKER
Thank you!