Solved

Delete the same files for multiple users

Posted on 2014-12-16
2
510 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
OfficeMate Freezes on login or does not load after login credentials are input.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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 …
Suggested Courses

627 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