1.

Solve : Delete all users except for some?

Answer»

I work in IT, and I have to remove USERS from loaner laptops all the time.  What I currently use to do this is:
" rmdir (username) /s/q "
rinse and repeat, but I would like to do something like
" rmdir * /s/q " then have the exception of administrator and my username and some others. (same on every laptop)

Any help would be much appreciated.

Side note: I prefer this METHOD over just deleting in windows because it doesn't ask any questions.  USER profiles are full of read-only and protected files.  This method deletes everything in the folder no matter what it is. Code: [Select]echo off
pushd "%USERPROFILE%\"
pushd ".."
for /D %%P in (*) do if not %%P==Administrator if not %%P==MyUserName echo %%P 
popd&popd

the echo there is a non-destructive PLACEHOLDER. You can add additional "if not %%P==Whatever" segments for additional profiles you wouldn't want to delete. Once you are happy with the list of folders it PROVIDES, you can replace the "echo %%P" with "rmdir %%P /s /q" to have it remove those folders.Awesome this worked very well, thank you.



Discussion

No Comment Found