Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I need help with a batch file, i need it to delete all folders, subfolders and files from C:\Documents and Settings except for five folders named:
Administrator
All Users
Default User
LocalService
NetworkServiceI found the code I need for this function, (http://www.computing.net/answers/programming/batch-file-help-delete-all-folder/13383.html)
But, I also need the ability to remotely connect to a list of computer's C: Drive's (via run > \\ComputerName\C$) and then run the batch file. I'd prefer to keep everything in the batch file (manually type in the computer names), but am more than happy to ref. a text file with the computer names etc.
Any suggestions on the code for this?
markey

Markey,
This script takes computer names from computer-names-list.txt and maps each entry to t: and so on ...
Replace {username} by the username used to map drive.
setLocal EnableDelayedExpansion
for /f %%b in (computer-names-list.txt) do (
net use t: %%b\c$ /user:{username}
:: Do the delete operations on t:
net use t: /d
)--
Holla.[EDITed Later]
Assumtion is that the computer-names-list.txt file contains computer namees prefixed with \\. ( I was using the output of net view). If it does not, add the slashes before %%b in the for loop while mapping the drive using net use command.

Just by deleting all the user's directories, you're not actually deleting the user accounts from the system. The users will still be able to login, and their directories will be re-created automatically. You need to use NET USER username /DELETE.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |