Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer avg black screen boot bsod computer connection crash css dell display driver drivers email error ethernet excel firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware monitor network networking outlook outlook 2003 outlook 2007 outlook express partition problem router slow software spyware trojan usb video virus vista wifi windows windows vista windows xp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
selective deleting folders in dos


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
pagla's Avatar
Computer Specs
Junior Member with 3 posts.
 
Join Date: Jul 2006
13-Jul-2006, 04:46 PM #1
selective deleting folders in dos
let me describe my situation again.
i have users loggin in to my labs. what i want to do is, delete their folders from
c:\documents and settings\[user_folder]

and only keep the administrator folder in there.
so i have:
c:\documents and settings\administrator
c:\documents and settings\userA
c:\documents and settings\userB
and so on ...

what this script should do is clean "documents and settings" folder by only keeping "administrator" and delete everything else.

I did get some help regarding this but its not complete yet. this is the closest i got so far.
Code:
::== keepADMN.bat
@echo off
dir /s/b/ad "C:\Documents and Settings" > allusers.txt
find /v /i "C:\Documents and Settings\Administrator" < allusers.txt > others.txt
find /v /i "C:\Documents and Settings\All Users" < others.txt > clear.txt
for /f "tokens=*" %%U in (clear.txt) do (
echo rmdir /q %%U )
:: DONE
pause
But dos won't delete because in clear.txt , the folder paths contain spaces.

so please help me. i'm almost there.
squidboy's Avatar
Computer Specs
Senior Member with 409 posts.
 
Join Date: Dec 2004
Location: Long Island, NY
Experience: Cheese makes my mouse wor
13-Jul-2006, 11:14 PM #2
Quote:
Originally Posted by pagla
let me describe my situation again.
i have users loggin in to my labs. what i want to do is, delete their folders from
c:\documents and settings\[user_folder]

and only keep the administrator folder in there.
so i have:
c:\documents and settings\administrator
c:\documents and settings\userA
c:\documents and settings\userB
and so on ...

what this script should do is clean "documents and settings" folder by only keeping "administrator" and delete everything else.

I did get some help regarding this but its not complete yet. this is the closest i got so far.
Code:
::== keepADMN.bat
@echo off
dir /s/b/ad "C:\Documents and Settings" > allusers.txt
find /v /i "C:\Documents and Settings\Administrator" < allusers.txt > others.txt
find /v /i "C:\Documents and Settings\All Users" < others.txt > clear.txt
for /f "tokens=*" %%U in (clear.txt) do (
echo rmdir /q %%U )
:: DONE
pause
But dos won't delete because in clear.txt , the folder paths contain spaces.

so please help me. i'm almost there.
Not picking on you pagla, but I've not really understood why folks choose to use DOS to address issues with Windows 2000/XP.

If I'm off my rocker and you really want to pursue this, we can try.

If you're open to easier solutions, let us know what you *really want to do* as Windows handles security issues much better than it used to via policies and other stuff. Hope that made sense.
StumpedTechy's Avatar
Distinguished Member with 6,142 posts.
 
Join Date: Jul 2004
Location: Central Florida
Experience: Advanced
14-Jul-2006, 11:20 AM #3
No offense squyidboy but no policy I know of will clean up profile directories off a PC.

The first question I have is WHEN do you want this script to run? If a user logs in then their profile will be locked and you can't delete it so you will also have to add the %username% to this as well if its a login script.

Is there a reason you want it as a batch and not as a VBS? I think you can do it alot easier with VBS and the - CreateObject("Scripting.FileSystemObject") and then using Delete folder command.

It could be as simple as a 3 line VBS depending on your User ID naming conevention.
DoubleHelix's Avatar
Distinguished Member with 9,214 posts.
 
Join Date: Dec 2004
Experience: A little of this...a little of that
14-Jul-2006, 11:51 AM #4
I think what squidboy means is that rather than deleting profiles through DOS or any other methods, perhaps there's a way to accomplish the true goal here (whatever that is).

It sounds to me like this organization does not want user profiles created on the computers and wants everyone to use Administrator.
pagla's Avatar
Computer Specs
Junior Member with 3 posts.
 
Join Date: Jul 2006
15-Jul-2006, 10:20 PM #5
First, Thanks all for your inputs.


ACtually I've tried using the group policy editor, but for some reason it didnt' work. that's why i'm trying to acheive it through DOS.
local comp poli \ computer config \ admin templates \ system \ user profile
and in there, i had enabled "delete cached copies of roaming profiles".

but even when users logs out, the folders are still there using up disk space.
---
Of course I can alternatively go into c:\documents and settings and press CTRL+A to do this, but for some reason I'm drawn to dos.

All i have to do is just double click on a single file.
---
Anyway, someone else helped me fine tuing the code i pasted above. i will test it out and let you know if it worked.
pagla's Avatar
Computer Specs
Junior Member with 3 posts.
 
Join Date: Jul 2006
15-Jul-2006, 10:28 PM #6
squidboy, I just want to clear their profiles when they leave labs. they take up much needed space.

stumpedtechy, in gpedit.msc, i have tried using it, but didn't get it work. try the path i posted, and if you get it to work, please let me know.
well, it doesn't have to be automated. i plan to run this batch script every friday manually.

doublehelix, no way bro. its just after users leave, we want to delete their profile folders as well. no way we want them to use admin account. lol.

Thanks again.
DoubleHelix's Avatar
Distinguished Member with 9,214 posts.
 
Join Date: Dec 2004
Experience: A little of this...a little of that
16-Jul-2006, 11:55 AM #7
Ah. I completely understand. Thanks for the clarification.
Squashman's Avatar
Distinguished Member with 12,688 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
16-Jul-2006, 01:08 PM #8
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:32 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.