+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
Windows Server 2000/2003 Thread, temp file delete in Technical; Hello , I need a script to delete users temp files i.e. cookies from the profiles on the workstations and ...
  1. #1
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18

    temp file delete

    Hello ,
    I need a script to delete users temp files i.e. cookies from the profiles on the workstations and server as we use roaming profiles or another solution for this ? checked a users profile on a workstation and 7000+ cookies. need to reduce log on and log off times.
    Any pointers please.

  2. #2

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,994
    Thank Post
    3,539
    Thanked 1,110 Times in 1,016 Posts
    Rep Power
    374
    what paths are you reffering to that you want to delete the items from ?

  3. #3
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18
    Quote Originally Posted by jinnantonnix View Post
    There's a setting in Active Directory to prevent temporary internet files beings copied across the network. If you can't find it, I'll dig out the settings.
    If you could that would be great.

  4. #4
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18
    Quote Originally Posted by mac_shinobi View Post
    what paths are you reffering to that you want to delete the items from ?
    The paths are from the workstation C:\Documents and Settings\dadams\
    Server path \\curricsvr1\Profiles$\dadams\cookies
    Last edited by MrPstv; 6th May 2010 at 10:48 AM.

  5. #5
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18
    Quote Originally Posted by jinnantonnix View Post
    In AD, under User Configuration>Administrative Templates>System>User Profiles
    there's a section to exclude any folders you want in a roaming profile.

    In the help, it says that - by default - History, Temp Internet files, etc are excluded from the roaming profiles.

    Are you sure everything's OK with your setup?

    P.S. There's also a setting to limit the profile size.
    Thanks for the info i will have a looky at group policy, but i still need a script to delete this unwanted temp files.

  6. #6
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18
    would this work for the workstations ?
    c:
    cd\
    cd C:\Documents and Settings\%username%\Local Settings\Temporary
    Internet Files
    del *.* /f/s/q
    cd \
    cd c:\Documents and Settings\%username%\Local Settings\Temp
    del *.* /f/s/q
    exit

  7. #7
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18
    Quote Originally Posted by jinnantonnix View Post
    You should be able to get away with

    Code:
    del /s /f /q "%userprofile%\Local Settings\Temporary Internet Files"    <<<- don't forget the quotes
    del /s /f /q %temp%
    del /s /f /q %tmp%
    %userprofile% is better than C:\Documents and Settings\%username% as it guarantees to hit the profile. As does the %temp% variables. I've included the lesser-used %tmp% just for the hell of it.
    Just tried it thanks , .It needs to be tweaked a tad to allow deletion of all users cookies from me running the script as adminstrator not just my own cookies.

  8. #8
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18
    can anyone shed a bit more light on this script please.

  9. #9

    Join Date
    Jan 2009
    Location
    Tavistock
    Posts
    318
    Thank Post
    67
    Thanked 128 Times in 59 Posts
    Rep Power
    46
    Hello,
    I have the same problems, user profiles are getting full up with pf*.tmp files (something to do with office) and thousands of cookies which are making profiles huge compared to normal (Size:83Mb, Size on disk:139Mb), I have the GPO setting that excludes some folders from roaming profiles but the ones it says are excluded by default are definutly not exculed, every other part of the GPO is working and this happens on 3 different sites that I work at. I have set up a test user and a fresh GPO and still the temp files and internet files are sent back to the server.

    Could your script be added to the log-off script in a GPO of each user or OU to delete the files before syncing back to the server or is the log-off script (applied by the GPO) loaded after the profile has been sent back to the server?

    Our pupil logons take about 1minute with a fresh profile but after a week its taking about 5-10minutes to logon. I know compared to some systems this is still fast but I have redirected the desktops, my documents, application data (all with offline access disabled) so the only files that are taking ages are the tmp files etc i guess.

    Another idea is, would changing all the profiles to manditory stop the temp files being written back to the server?

    Thank you for any help

    Quote Originally Posted by jinnantonnix View Post
    You should be able to get away with

    Code:
    del /s /f /q "%userprofile%\Local Settings\Temporary Internet Files"    <<<- don't forget the quotes
    del /s /f /q %temp%
    del /s /f /q %tmp%
    %userprofile% is better than C:\Documents and Settings\%username% as it guarantees to hit the profile. As does the %temp% variables. I've included the lesser-used %tmp% just for the hell of it.

  10. #10
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18
    apologies for my lack of knowledge in scripting but do i add the above script to the previous script or use this as is? Thankyou for your help again.

  11. #11

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,158
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    I think this is approaching it from the wrong end; you would be better to delete them from the server copy overnight. When a user logs on the next day they will copy down a clean profile.

    On the server I'm guessing you've got profiles in (say) d:\profiles with each user under that:
    d:\profiles\david
    d:\profiles\gordon
    d:\profiles\nick

    etc

    If this is the case then you want to create a batch file like this:
    Code:
    d:
    cd \profiles
    for /d %%i in (*) do rd "%%i\cookies" /s /q
    What this does is change to the correct drive and folder. The for statement then looks for each directory (/d switch) and executes the stuff after "do" for each one, substituting its name for the %%i bit

    Schedule this to run overnight (or do it manually when you know most people are logged off)

    If you want to check what it's doing then add a pause command:
    Code:
    for /d %%i in (*) do rd "%%i\cookies" /s /q & pause
    This will do the first rd command and then wait for you to press a key - you can then see if it did the right thing! (Make a dummy profile called 11111 or something which comes at the top of the alphabetical list for safety)

    If your folder structure is different from this (eg split by year) then you should be able to do something like this:

    Code:
    d:
    cd \profiles\year7
    for /d %%i in (*) do rd "%%i\cookies" /s /q
    
    cd \profiles\year8
    for /d %%i in (*) do rd "%%i\cookies" /s /q
    
    cd \profiles\year9
    for /d %%i in (*) do rd "%%i\cookies" /s /q
    - just adding extra pairs of lines for each year group.

    You can then schedule this to run every night.

    I'm sort of surprised that this is causing a problem - cookies are supposed to be very small files (typically well under 1kb) My own cookie folder is only 15kb in size so unless something is storing stuff in cookies which shouldn't be there then I don't know if this is the problem.

    I would look at the profiles for a couple of users with problems using (eg) Treesize - JAM Software - Windows Freeware This will show you which folders in the user's profile are taking up the space and slowing things down.

    Finally (!) you might want to look at redirecting cookies to the user's home drive - that way they don't get copied at logon/off so you don't have to worry about how long they take. Redirect Favorites and Cookies folder using a Group Policy has a good article on how to do this.

  12. #12

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,158
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    I think this is approaching it from the wrong end; you would be better to delete them from the server copy overnight. When a user logs on the next day they will copy down a clean profile.

    On the server I'm guessing you've got profiles in (say) d:\profiles with each user under that:
    d:\profiles\david
    d:\profiles\gordon
    d:\profiles\nick

    etc

    If this is the case then you want to create a batch file like this:
    Code:
    d:
    cd \profiles
    for /d %%i in (*) do rd "%%i\cookies" /s /q
    What this does is change to the correct drive and folder. The for statement then looks for each directory (/d switch) and executes the stuff after "do" for each one, substituting its name for the %%i bit

    Schedule this to run overnight (or do it manually when you know most people are logged off)

    If you want to check what it's doing then add a pause command:
    Code:
    for /d %%i in (*) do rd "%%i\cookies" /s /q & pause
    This will do the first rd command and then wait for you to press a key - you can then see if it did the right thing! (Make a dummy profile called 11111 or something which comes at the top of the alphabetical list for safety)

    If your folder structure is different from this (eg split by year) then you should be able to do something like this:

    Code:
    d:
    cd \profiles\year7
    for /d %%i in (*) do rd "%%i\cookies" /s /q
    
    cd \profiles\year8
    for /d %%i in (*) do rd "%%i\cookies" /s /q
    
    cd \profiles\year9
    for /d %%i in (*) do rd "%%i\cookies" /s /q
    - just adding extra pairs of lines for each year group.

    You can then schedule this to run every night.

    I'm sort of surprised that this is causing a problem - cookies are supposed to be very small files (typically well under 1kb) My own cookie folder is only 15kb in size so unless something is storing stuff in cookies which shouldn't be there then I don't know if this is the problem.

    I would look at the profiles for a couple of users with problems using (eg) Treesize - JAM Software - Windows Freeware This will show you which folders in the user's profile are taking up the space and slowing things down.

    Finally (!) you might want to look at redirecting cookies to the user's home drive - that way they don't get copied at logon/off so you don't have to worry about how long they take. Redirect Favorites and Cookies folder using a Group Policy has a good article on how to do this.

  13. 2 Thanks to srochford:

    JAB1a (7th May 2010), MrPstv (7th May 2010)

  14. #13

    Join Date
    Jan 2009
    Location
    Tavistock
    Posts
    318
    Thank Post
    67
    Thanked 128 Times in 59 Posts
    Rep Power
    46
    Thank you srochford,

    your batch file worked perfectly. I will trial adding a hidden folder to the users home directory which will have the cookies folder redirected to it and see how it goes, Im in the worst offending site on thursday so will let you know about the treesize figures of the profiles there.

    The cookie folder in profiles at this site is about 700Kb but size on disk was about 6.8Mb but all gone now

  15. #14
    MrPstv's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham
    Posts
    273
    Thank Post
    32
    Thanked 13 Times in 9 Posts
    Rep Power
    18
    Hello ,
    Just to clarify something,
    We have students with individual logons example 03testa ,03haveago,03itdontwork,03pullmyhairout. We have this set up for 400 students and the staff are setup as example bbuilder, how would i apply this in the script? the drive letter is x , or \\curricsvr1\profiles$,
    sorry but i just cant get my head around scripts!!!

  16. #15

    Join Date
    Jan 2009
    Location
    Tavistock
    Posts
    318
    Thank Post
    67
    Thanked 128 Times in 59 Posts
    Rep Power
    46
    Big thanks to SRochford with his script thats its now nice and simple..

    To make the script just open Notepad and copy&paste the code into a new text document, then save as and change the file type to 'all files' and then remember to add the .bat to the file name (script.bat).

    If you are running this on the server then this is the code I think you should use (this is asuming that the partition you have the Profiles$ folder on is drive letter X: and that the profiles folder is at the root of the drive (X:\profiles) if its not then change the drive letter in the script to the one you need and add the parent folders name/s before the \profiles (cd studentfolder\profiles)

    Code:
    X:
    cd \profiles
    for /d %%i in (*) do rd "%%i\cookies" /s /q & pause

    If you are running this from a workstation logged in with admin rights on the server then you can just map a drive letter to the folder or use this script

    Code:
    NET USE X: \\curricsvr1\profiles$
    X:
    for /d %%i in (*) do rd "%%i\cookies" /s /q & pause
    as SRochford says you should make a temp profile folder with the name 0000 inside your profile folder so it definutly comes first and then add a cookies folder inside it. both the scripts have the added pause so you can use it just on your temp profile folder and cancel if something is not right.

    I hope this helps, and if it works then please just us know



SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Sysprep config – delete a text file
    By FN-GM in forum Windows
    Replies: 12
    Last Post: 16th September 2008, 01:57 PM
  2. Cannot delete file
    By adamf in forum Windows
    Replies: 3
    Last Post: 14th August 2008, 12:35 PM
  3. temp or temp to perm sharepoint install engineer Łneg
    By SpecialAgent in forum Educational IT Jobs
    Replies: 1
    Last Post: 20th March 2008, 11:15 AM
  4. Delete certain file format using a script
    By FN-GM in forum Scripts
    Replies: 3
    Last Post: 27th December 2007, 01:17 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •