• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 440
  • Last Modified:

Script to delete all documents from My Documents and Desktop of a specific user

Hi, I am looking for a log on or log off script which can be pushed out with group policy which will delete all documents in the My Documents and Desktop of a specific user.

The script should proceed on errors and hopefully leave a log file of results (files skipped and deleted) in the c:\

  • 2
2 Solutions
Would a Mandatory Profile be an option for you? If you are only looking to delete from those two folders, maybe not, but if you want NO changes saved at logoff, might be an option....
 Create an XP Pro Mandatory User Profile on the Local Machine
Might not be what you need, but thought I would offer....
Her si a fast brain dump
make 2 batches.  the first does the work, the second starts the first file and logs its progress.


:::: file_clean.bat
del /f /y C:\documents and settings\user\desktop\
del /f /y C:\documents and settings\user\Mydocuments\
:::: Run_and_log.bat
start File_clean.bat >> log.txt

Open in new window

susnewyorkAuthor Commented:
Mandatory profile is definatly not an option for me.
Is this going to be the currently logged in user, so the same script will need to run on each PC?
I would actualy use the following syntax.....
del /f /y %USERPROFILE%\desktop\*.*
del /f /y %USERPROFILE%\user\Mydocuments\*.*
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now