Solved

Delete the same files for multiple users

Posted on 2014-12-16
2
384 Views
Last Modified: 2014-12-17
I have a terminal server running Windows 2008 R2 with about 100 users.  On each user's desktop, there is a folder.  I need to schedule a weekly batch file to delete the files inside of this folder for all users.

For one user, I can use this simple batch file:
     cd C:\Users\<username>\Desktop\ToBeDeleted
     Del *.* /Q

Is it possible to delete the contents of the "ToBeDeleted" folder for all users - all folders that are in C:\Users?
0
Comment
Question by:David_XF
2 Comments
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 500 total points
ID: 40503822
Problem is, unless you've modified the permissions, they prevent even admins from casually deleting files/folders within the user profile in 2008 and later.  IF you DO modify the permissions, you can use a for command to cycle through all the folders.

for /f %a in ('dir /ad /b c:\users\') do @del c:\users\%a\desktop\ToBeDeleted

(note, if you use that in a batch file, you need to double the percents - %%a)
0
 

Author Comment

by:David_XF
ID: 40505297
That works perfectly.  Thanks for the help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now