+ Post New Thread
Results 1 to 15 of 15
Wireless Networks Thread, Deleting all files from users home dirrectorys in Technical; We have decided to delete all users files from their home dirrectorys. Does anyone have a script or utility to ...
  1. #1

    Join Date
    Dec 2007
    Posts
    84
    Thank Post
    2
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Deleting all files from users home dirrectorys

    We have decided to delete all users files from their home dirrectorys. Does anyone have a script or utility to carry out this task?

  2. #2


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,697
    Thank Post
    352
    Thanked 803 Times in 718 Posts
    Rep Power
    348
    A for loop script could do this, are all of your home directories under one path ie. e:\users or so?

  3. #3

    Join Date
    Dec 2007
    Posts
    84
    Thank Post
    2
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Thanks for your response, Yes all our users are under one path.

  4. #4


    Join Date
    Sep 2007
    Location
    UK
    Posts
    5,463
    Thank Post
    1,462
    Thanked 892 Times in 573 Posts
    Rep Power
    647
    I just mapped the students folder as a network drive, used FIND to display all files and deleted them.

  5. #5

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Not sure if you really want to delete all user files (staff? administrator?) but you can use the following code to do that.

    The key line contains:
    <LDAP://ou=to be deleted," & sRoot & ">

    If you take out "ou=to be deleted" then it will delete every file in every user's home directory - use with care!!!

    If you've got an OU for each year group then you might use:

    <LDAP://ou=year11," & sRoot & ">
    or
    <LDAP://ou=year13,ou=pupils," & sRoot & ">

    What I would do is to set up the code below but replace DeleteFolder sHomeDir with wscript.echo sHomeDir - you'll then see a list of folder names but they won't actually get deleted. When you're sure this is the right set of users you can go ahead and put back the delete line.

    Just for info, I'm doing the delete a file at a time because if you try and delete a folder and 1 file is locked then the rest of the folder gets left behind. Like this, you might get a few odd files left behind to tidy up manually but most will be cleaned up.

    Code:
    Dim sRoot
    Set oRootDSE=GetObject("LDAP://RootDSE")
    sRoot=oRootDSE.Get("rootDomainNamingContext")
    Set oFSO=wscript.createobject("scripting.filesystemobject")
    Set oConn2 = CreateObject("ADODB.Connection")
    
    oConn2.Provider = "ADsDSOObject"
    oConn2.Open
    Set oCommand = CreateObject("ADODB.Command")
    oCommand.ActiveConnection = oConn2
    oCommand.properties("Page Size")=1000
    
    
    oCommand.CommandText = "<LDAP://ou=to be deleted," & sRoot & ">;(&(objectCategory=person)(sn=*));sAMAccountName,adspath,cn;subTree"
    set oRS2=oCommand.execute
    do while not oRS2.eof
      set oUser=getobject(ors2("adspath"))
      wscript.echo "deleting " & oUser.name
      sHomeDir=""
      on error resume next
      sHomeDir=ouser.get("homedirectory")
      on error goto 0
      if sHomeDir<>"" then
        if oFSO.folderexists(sHomeDir) then
        DeleteFolder sHomeDir
        end if
      oRS2.movenext
    loop
    
    Sub DeleteFolder(sRoot)
      on error resume next
      Set oFolder=oFso.getfolder(sRoot)
      For Each folder In oFolder.subfolders
          ClearContents(folder)
      Next
      ClearContents(oFolder)
      on error goto 0
    end sub
    
    Sub ClearContents(sFolder)
      on error resume next
      for each f1 in sFolder.files
        ofso.deletefile f1,true
      next
      For Each f2 In sFolder.subfolders
        ClearContents(f2)
        ofso.deletefolder f2,true
      Next
      on error goto 0
    End Sub

  6. #6

    bossman's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    3,964
    Thank Post
    1,209
    Thanked 1,074 Times in 765 Posts
    Rep Power
    332
    @noser:

    May I ask the question, why do you want to delete all user files from their home directory?

    Have you already copied them to another place?

    We copy our final year students work to another place and then back them up onto DVDs and Archive them as our Final year students may need the work for future use, then and only then do we delete from the servers.

  7. #7


    Join Date
    Sep 2007
    Location
    UK
    Posts
    5,463
    Thank Post
    1,462
    Thanked 892 Times in 573 Posts
    Rep Power
    647
    I do it because, no matter how much I try, I cannot get the kids to keep their folders tidy. So now I back everything onto dvd and then delete it from the server. If anyone needs a file they have to come to me and ask for it. In the 3 years or so I've been doing this, I haven't been asked once. This is just the students not staff.

  8. #8

    bossman's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    3,964
    Thank Post
    1,209
    Thanked 1,074 Times in 765 Posts
    Rep Power
    332
    @laserblazer:

    Why would you be bothered about their personal space?

    I find that if you give the students the right amount of space to save their work to and not too much it is up to the ICT teaching staff to ensure that the students create a folder structure which reflects a tidy solution.

    It is not up to us to say how they use the disk space allocated to them except for misuse in uploading illegal files or inappropriate material.

  9. #9


    Join Date
    Jan 2006
    Posts
    8,202
    Thank Post
    442
    Thanked 1,032 Times in 812 Posts
    Rep Power
    339
    we just give em appropriate quota's with limits on the maximum file size, max no of files etc. They get email when over quota and have a 'grace period' to get their things in order.

    ICT organisation is an important lifeskill, and less admin if you get your users to look after their own stuff

  10. #10


    Join Date
    Sep 2007
    Location
    UK
    Posts
    5,463
    Thank Post
    1,462
    Thanked 892 Times in 573 Posts
    Rep Power
    647
    Quote Originally Posted by CyberNerd View Post
    ICT organisation is an important lifeskill, and less admin if you get your users to look after their own stuff
    and what did your mum say she'd do if you didn't keep your bedroom tidy?

    As I said, nobody has ever asked for an old file back.

  11. #11

    bossman's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    3,964
    Thank Post
    1,209
    Thanked 1,074 Times in 765 Posts
    Rep Power
    332
    @laserblazer:

    My Mum told me only once and then proceeded to let my room fill up with dirty clothes and other things, when I got sick of not having any clean clothes to wear or could not find anything it suddenly dawned on me to tidy things up.

    It is only when someone else does it for you that you become lazy and will not do it yourself, as our end users eventually learn that to use IT effectively they themselves have to work at tidying their environment up.

    Your not teaching them anything by taking things away, just that they have a clean space to mess up again. As has been mentioned IT is a lifeskill and something that has to be learned just like any other skill.

  12. #12


    Join Date
    Sep 2007
    Location
    UK
    Posts
    5,463
    Thank Post
    1,462
    Thanked 892 Times in 573 Posts
    Rep Power
    647
    During the holidays, our school had a deep clean and the painters are still here finishing off. The mess that the kids made emptying waste into the skip at the end of term has been cleaned up and the school is spick and span. I doubt the kids will notice this when they come back, same as most won't notice their folders are empty. They are told how to keep organised but they are 9/10 year olds and it doesn't sink in. The teachers don't reinforce it, so I just find it easier to start the year with a clean slate. It's not as if I am removing anything permanently.

  13. #13

    Join Date
    Nov 2007
    Location
    Rotherham
    Posts
    1,678
    Thank Post
    122
    Thanked 126 Times in 102 Posts
    Rep Power
    46
    But then how do they learn?
    Stick a quota on and then show them how to organise their work when they run out of space...

  14. #14


    Join Date
    Sep 2007
    Location
    UK
    Posts
    5,463
    Thank Post
    1,462
    Thanked 892 Times in 573 Posts
    Rep Power
    647
    There is a quota, it's not the running out of space that's the issue, it's more the half a dozen versions of the same powerpoint and multiples of images they have downloaded and will never use. I appreciate that they should be taught how to organise their work but it doesn't happen in practice.

    Anyway, we are getting away from the point, the OP asked how to bulk delete user files and I said how I do it without resorting to scripts.

  15. #15

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Quote Originally Posted by laserblazer View Post
    Anyway, we are getting away from the point, the OP asked how to bulk delete user files and I said how I do it without resorting to scripts.
    But if you don't ask questions you never learn new and interesting things :-)

    I understand what you are doing and why but I don't think it's a good idea. If users are running out of disc space then they need to delete stuff they don't use - it is a skill they need to learn.

    If the files need deleting because a school can't afford enough disc space to give sensible quotas then the idea of deleting the content is reasonable (assuming it has been backed up somewhere just in case!)

    Finally, while avoiding scripting can be a good idea and works well for a small school it's really not viable if you've got even 1,000 users let alone 10,000 or more (and many posters here do have that sort of network)

SHARE:
+ Post New Thread

Similar Threads

  1. prevent users from deleting start menu items
    By techie211 in forum Windows Server 2000/2003
    Replies: 10
    Last Post: 1st September 2009, 03:58 PM
  2. Accessing users files via Sharepoint?
    By rpycroft in forum Virtual Learning Platforms
    Replies: 7
    Last Post: 28th April 2009, 09:19 PM
  3. problems deleting users
    By DirtySnipe in forum EduGeek Joomla 1.5 Package
    Replies: 1
    Last Post: 12th March 2009, 12:47 PM
  4. Replies: 2
    Last Post: 20th August 2007, 09:52 AM
  5. Error deleting files or folder message
    By speckytecky in forum How do you do....it?
    Replies: 1
    Last Post: 15th November 2006, 02:21 PM

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
  •