Hi Kaseya Friends,
I have a unique situation where I am trying to delete some files out of a folder and leave the folder in tact. I need the user to be a wildcard because whatever script or procedure that is written should be able to go through all of the user profiles on the machine and delete these files out of the folder.
Ex: c:\users\user\appdata\local\temp (user is the wildcard)
Any suggestions on how to make this happen?
So to recap;
Try these commands;
FOR /D %X IN ("C:\Users\*") DO FOR /D %Y IN ("%X\appdata\local\temp\*.*") DO RMDIR /S /Q "%Y"
FOR /D %X IN ("C:\Users\*") DO FOR /F %Y IN ("%X\appdata\local\temp\*.*") DO DEL /S /Q "%Y"
or this as a batch file;
FOR /D %%X IN ("%SRC1%\*") DO FOR /D %%Y IN ("%%X\%SRC2%\*.*") DO RMDIR /S /Q "%%Y"
FOR /D %%X IN ("%SRC1%\*") DO FOR /F %%Y IN ("%%X\%SRC2%\*.*") DO DEL /S /Q "%%Y"
Are all the location local to each system?? Or are some networked?
The locations are local on the C: drive - what's happening is the computers having the issue are lab machines so they have a lot of users logging in and this appdata\local\temp folder is getting huge and sending alerts because the computers are running out of hard drive space. Rather than go in and manually remove all those files within the temp folder (I did this the other night it took hours); I'd like to automate the process.
I found a script that you can save as a vbs then call using agent procedures. The script I found is at www.cedit.biz/.../delete-temporary-files-from-all-users-profiles
I have comfirmed that this does delete your specified files. It also deletes windows/temp/*
or if you want to run it from a batch file;
Closer than I was HardKnoX! Did the batch file, ran as administrator, it is deleting the folders within appdata\local\temp but it is not deleting the files.
And this to get the file in the root of the temp folder;