+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
Windows Server 2000/2003 Thread, temp file delete in Technical; Originally Posted by srochford I think this is approaching it from the wrong end; you would be better to delete ...
  1. #16

    Join Date
    Jun 2010
    Posts
    198
    Thank Post
    9
    Thanked 25 Times in 24 Posts
    Rep Power
    21
    Quote Originally Posted by srochford View Post
    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.
    Well done srochford .This is the way I do it directly on the server but I don't bother with cookies as these are dealt with by GPO not copying back IE temp files etc.. I do delete the following though *.exe *.cmd *.bat *.wmv and a whole host of other extensions I have one script with a list of students folders which checks every 15 minutes to deal with repeat offenders who copy exe's and mp3's to their home folder.

    Just one thing I would add to the script and thats the following

    Code:
    cd /d d:
    ( or whatever drive the script started from) This one from experience when Microsoft made changes to the cmd program and a windows server update had my script on completing the sweep of students folders happily jumped from the d: drive to c:\windows\system and started to delete all the exe's.
    So make sure you return the script to the relevant drive with
    Code:
    cd /d d:
    ( or whatever your drive letter is) and put in an exit command to close the session

    Code:
    exit
    ( and the exit cmd to close the cmd session)

    Kili

  2. #17

    Join Date
    Jan 2009
    Location
    Tavistock
    Posts
    315
    Thank Post
    66
    Thanked 127 Times in 58 Posts
    Rep Power
    46
    Hi Kili,

    Thanks for your post, could you possible post your script on here so I could take a look at the syntax

    Thank for your time

  3. #18

    Join Date
    Jun 2010
    Posts
    198
    Thank Post
    9
    Thanked 25 Times in 24 Posts
    Rep Power
    21
    Quote Originally Posted by JAB1a View Post
    Hi Kili,

    Thanks for your post, could you possible post your script on here so I could take a look at the syntax

    Thank for your time

    This is the script I use for deleting from Teachers Home folders and profiles.
    Place the script on the drive you want to run it from in my case it's drive D

    Code:
    REM -------- If you make changes to this file please leave your name and date of editing --- 
    
    
    REM ------ Change focus to drive D: data\home folders\teaching staff --------
    REM 
    cd /d d:\"Data\home folders\teaching staff"
    del *.flv *.avi *.qt *.msi *.zip *.tmp *.exe *.mp3 *.mp4 *.m4p *.wma *.temp *.acc *.cda *.mpeg *.mov *.wmv *.wma *.asx *.mpg *.asf *.wav *.m3u *.m4a *.mpg *.bak *.xbk /s 
    
    
    REM ------ Change focus to drive D: data\Shared Data --------
    REM 
    REM Only enable script below if schedtask account has access and you want to delete these file types
    cd /d d:\"Data\Shared Data"
    del *.flv *.avi *.qt *.msi *.zip *.tmp *.exe *.mp3 *.mp4 *.m4p *.wma *.temp *.acc *.cda *.mpeg *.mov *.wmv *.wma *.asx *.mpg *.asf *.wav *.m3u *.m4a *.mpg *.bak *.xbk /s 
    
    
    
    REM ------ Change focus to drive D: data\profiles\teaching staff to reduce profile size on logon--------
    REM-------
    REM------- xml files added for deletion from profiles as long xml file names causing profiles to fail loading.
    REM-------
    cd /d d:\"Data\Profiles\teaching staff"
    del *.flv *.avi *.qt *.msi *.zip *.tmp *.exe *.mp3 *.mp4 *.m4p *.wma *.temp *.acc *.cda *.mpeg *.mov *.wmv *.wma *.asx *.mpg  *.asf *.wav *.m3u *.m4a *.mpg *.bak *.xbk *.xml /s 
    
    
    REM ------ Return focus to drive d: and exit ------
    cd /d d:\
    
    exit
    This script is for deleting from student folders. I do not allow students to have roaming profiles as this simplifies management of students.
    Place the script on the drive you want to run it from in my case it's drive D

    Code:
    REM ---------- CHANGE FOCUS TO DRIVE D: AND MOVE TO STUDENTS HOME FOLDERS AND DELETE ILLEGAL FILES
    
    cd /d d:\"data\home folders\students"
    
    del *.flv *.3gp *.tmp *.exe *.mp3 *.stk *.piv *.ram *.mid *.mp4 *.tmp *.js *.acc *.zip *.lnk *.cda *.mov *.mpeg *.asx *.asf *.wav *.wma *.wmv *.m3u *.m4a *.mpg *.bak *.swf *.url /s > delhunt.log
    
    REM -------------RETURN TO D: AND EXIT
    cd /d d:\
    
    exit
    Obviously the paths will be different for your server. make sure the paths are correct and ensure you end the script with the focus back on to the drive you started from and use the exit command to close the script as you don't want the script to jump drives and cause havoc on the system drive.

    Create a dedicated account ( something like schedtask) for running the script and give it the appropriate permissions and then assign the account to have full control over the folders you want it to access . Dont use your main domain or server administrator account as the password should be changed on a regular basis and when you change it if you've used the administrator account for your script the job will fail because it has the wrong password set in the scheduled task properties

    It's not the best batch filing you'll see but it works for me.

    Hope this is of some help

    Kili
    Last edited by kili; 14th June 2010 at 11:14 AM.

  4. #19

    Join Date
    Jun 2010
    Posts
    198
    Thank Post
    9
    Thanked 25 Times in 24 Posts
    Rep Power
    21
    [QUOTE=srochford;505237]
    Code:
    d:
    cd \profiles
    for /d %%i in (*) do rd "%%i\cookies" /s /q

    Hi Steve , is it possible to adapt the above to delete profile folders from workstations where it generates profiles folders such as
    anyname
    anyname001
    anyname002
    anyname003

    and so on. I have delete roaming profiles on log off set in GPO but of course this does not always work . I have psexec from sysinteranls which allows me to send to a command prompt to a list of workstations from a file. If I could adapt this for statement to delete profiles with certain strings of letters in them (anyname001
    anyname002) it would help me with a few issues regarding profiles.

    for instance one individual has a hugh profile and has used over 50 different computers

    regards

    Kili

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

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