Home
»
Discussion Forums
»
Scripts & Agent Procedures
»
Script to delete files in users folder?
Subscribe via RSS
Share this
Similar Posts
Deleting files in a folder Script
by
LegacyPoster
on
Feb 6, 2009
Delete file under user's profile startup folder.
by
LegacyPoster
on
Jul 31, 2008
A batch script to delete a file in startup folder
by
Mawata
on
Oct 30, 2013
Script To Delete All But The Most Recent Files In A Folder
by
Wayne
on
Oct 18, 2011
Verified Answer
Ways to delete files in a folder?
by
LegacyPoster
on
Jul 29, 2009
View More
Details
5
Replies
0
Subscribers
Posted
over 11 years ago
Scripts & Agent Procedures
Script to delete files in users folder?
Posted by
LegacyPoster
on
May 28, 2009 5:35 AM
I'm trying to figure out an easy way to delete everything in a users folder, without deleting the users folder itself.
So with a structure like this:
c:\users\gsmith
c:\users\alincoln
c:\users\jdoe
etc... etc.
I want to delete EVERYTHING under the users directory, with out deleting the named top level directory (gsmith, alincoln, etc)
I have to clean out 2500+ folders. Any ideas would be greatly appreciated.
Thanks,
Jason
Legacy Forum Name: Script to delete files in users folder?,
Legacy Posted By Username: jasonmh
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
May 28, 2009 9:55 AM
I started working on this a couple weeks ago. The idea was that is a laptop or computer was stolen I could run this script if it was ever turned on and accessed the internet.
I have not had time to test it though but it should do what you are looking for and will not remove the folders..
Let me know how it works out.
Script Name: Delete User Files
Script Description: Script to delete user files:
XP/2000: c:\documents and settingsVista: c:\users\
IF True
THEN
Execute Shell Command
Parameter 1 : del /f /q /s c:\documents and setting\*.*
Parameter 2 : 0
OS Type : 8
Execute Shell Command
Parameter 1 : del /f /q /s c:\documents and setting\*.*
Parameter 2 : 0
OS Type : 3
Execute Shell Command
Parameter 1 : del /f /q /s c:\users\*.*
Parameter 2 : 0
OS Type : 10
Write Script Log Entry
Parameter 1 : Users files deleted
OS Type : 10
ELSE
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: mlnetcor
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
May 28, 2009 9:25 PM
thank you very much, i'll give it a try today and post back.
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: jasonmh
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
May 28, 2009 9:50 PM
That worked really well. It left the subfolders (folders below the c:\users\user1\..), but it removed all the files in the subfolders, which was all I really needed. Thanks again.
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: jasonmh
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Feb 15, 2010 2:13 PM
Could have also used:
rmdir C:\Directory /S /Q
Cheers,
Greg
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: glipschitz
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
Posted by
LegacyPoster
on
Feb 19, 2010 1:21 AM
I had to do same task for other folders and I did a different method.
K2 server
I created a batch file, upload to Kserver and then have the script write , execute and delete batchfile. I found it to be faster (in writing terms) then writing agent procedures for doing the same thing.
IDK if bandwidth is an issue since the batchfile is so small anyway.
No idea if you can write in notepad and import in K2 for procedures, it probably would be faster.
Legacy Forum Name: Scripts Forum,
Legacy Posted By Username: Hasani
You have posted to a forum that requires a moderator to approve posts before they are publicly available.