Solved

How do I make a script to delete files I specify, from hundreds of different directories? (Or a program that will do it for me)

Posted on 2008-06-12
10
217 Views
Last Modified: 2010-04-16
Hi Experts

I'm a systems administrator at a school with over 1000 student accounts. We've had quite a number of kids bringing games and unwanted material into the school, and storing it on their home drives.

What I would like to do is have a utility that scans all these folders at night time looking for files I specify, and delete them. A Batch file or something. I have a large list of files that I know I wan't removed without question (like quake system files, flash games etc) I just need to give them to a program to deal with them.

Can anyone help, or suggest some software that will do this for me?

Kind of like a Virus scanner, but one that allows me to specify what it scans for.

Thanks

Jono
0
Comment
Question by:jonathanpace
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 9

Expert Comment

by:authen-tech
ID: 21776014
You might want to look into something like the Shared Computer Toolkit (now known as SteadyState)
http://www.microsoft.com/downloads/details.aspx?FamilyId=D077A52D-93E9-4B02-BD95-9D770CCDB431&displaylang=en

It will let you lock down the computers after you get them cleaned up and not allow for the installation of such files.  
0
 

Author Comment

by:jonathanpace
ID: 21776084
Thats not what I am after. The computers are locked down tight.

The students are copying things from USB memory keys onto their home drives. Movies, games that don't need to be installed, etc.

I want something server side where the home folders are stored to hunt down and destroy these kinds of things at night time.
0
 

Author Comment

by:jonathanpace
ID: 21776132
oh, whatever I use needs to be able to search for things I specify, because we can't just go and delete "*.wmv" and things like that because there are student assignments that are stored in the format etc.

Are there any programs out there?
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 7

Expert Comment

by:ManicD
ID: 21777526
You could try a software restriction policy. it wouldnt remove the files but it would stop them being accessable to students. Then afater a while once the theory that they can be used has spread a simple windows search and delete should remove the rubbish.


More information.
http://support.microsoft.com/kb/324036
http://technet.microsoft.com/en-us/library/bb457006.aspx
0
 

Author Comment

by:jonathanpace
ID: 21777688
I don't need any restriction policies as everything is locked down via group policy.

And installing software on individual PC's is out of the question, as there is over 1000 of them..

I need something server side, that will search for files that I specify in a bulk list. That way I can run it every night to remove any software automatically that I have specified in this list.

Will be easy because we have one server storing all the home folders, so it would just trawl through these folders deleting the stuff specified.

I was going to write a batch file and use "/s" commands, but if I specified 100 different files, then it would have to trawl through over 1000+ folders one at a time searching 100 times, and that would take too long and kill the disks from excessive flogging every night.


I'm running out of ideas..
0
 
LVL 22

Accepted Solution

by:
Paka earned 125 total points
ID: 21782467
Since you're only looking for file names, the batch delete method should only scan the MFT (not the entire disk) and won't flog your drives too badly.

You might be able to create virus signatures for the "bad" software and add it to the virus signatures.  I know that the Symantec SMTP anti-virus lets you define bad software names and it will quarratine/delete these files.
0
 

Assisted Solution

by:WendyDun
WendyDun earned 125 total points
ID: 21810222
Use Powershell and have a script something like the following.

You can modify it to work on whole directories as well - simply pass a high level directory name in as the filter and add the "-recurse" option to the Remove-Item line.
Function delFiles ($TargetFolder, $filter)
{
    $files = get-childitem $TargetFolder -recurse -filter $filter
    if ($files -eq $null) {return} #oddly, if nothing is returned, the foreach will do one iteration
    foreach ($f in $files)
    {
        write-host "Deleting File $f" -foregroundcolor "Red"
        Remove-Item $f.FullName -force # force ensures that readonly files are deleted. 
    }
}
 
# the filter will accept wildcards or exact matches
delFiles "c:\" "*.bad" 
delFiles "c:\" "FileNamed.xxx"

Open in new window

0
 

Author Comment

by:jonathanpace
ID: 21851017
I will try this and get back to you. Thanks for your help.
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains the steps required to use the default Photos screensaver to display branding/corporate images
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question