1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

selective deleting folders in dos

Discussion in 'DOS/Other' started by pagla, Jul 13, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. pagla

    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.
     
  2. squidboy

    squidboy

    Joined:
    Dec 29, 2004
    Messages:
    403
    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.
     
  3. StumpedTechy

    StumpedTechy

    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.
     
  4. DoubleHelix

    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.
     
  5. pagla

    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.
     
  6. pagla

    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.
     
  7. DoubleHelix

    DoubleHelix Banned

    Joined:
    Dec 9, 2004
    Messages:
    24,388
    Ah. I completely understand. Thanks for the clarification.
     
  8. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
  9. Sponsor

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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/482965

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice