Solved

Delete the same files for multiple users

Posted on 2014-12-16
2
459 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
[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
2 Comments
 
LVL 96

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
OfficeMate Freezes on login or does not load after login credentials are input.
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…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

751 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