selective deleting folders in dos

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

pagla

Thread Starter
Joined
Jul 13, 2006
Messages
3
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.
 
Joined
Dec 29, 2004
Messages
403
pagla said:
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.
 
Joined
Jul 7, 2004
Messages
7,235
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

Banned
Joined
Dec 9, 2004
Messages
24,388
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

Thread Starter
Joined
Jul 13, 2006
Messages
3
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

Thread Starter
Joined
Jul 13, 2006
Messages
3
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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top