Solved

Delete the same files for multiple users

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Redirected folders in a windows domain can be quite useful for a number of reasons, one of them being that with redirected application data, you can give users more seamless experience when logging into different workstations.  For example, if a use…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
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…

785 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