Computing.Net > Forums > Programming > Remotely Run Batch File from List

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Remotely Run Batch File from List

Reply to Message Icon

Name: markey
Date: November 18, 2008 at 09:22:01 Pacific
OS: XP SP2
CPU/Ram: T7100 1.8hgz, 1gb
Product: Dell
Comment:

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
NetworkService

I 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



Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: November 19, 2008 at 00:40:24 Pacific
Reply:

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.


0

Response Number 2
Name: klint
Date: November 19, 2008 at 02:14:57 Pacific
Reply:

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.


0

Response Number 3
Name: markey
Date: November 19, 2008 at 08:05:44 Pacific
Reply:

I appreciate the responses and apologize for my batch file ignorance. Thanks again

markey


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Remotely Run Batch File from List

how to call a batch file from html www.computing.net/answers/programming/how-to-call-a-batch-file-from-html/1539.html

Batch file to list dir name www.computing.net/answers/programming/batch-file-to-list-dir-name-/17362.html

running batch files within an .exe www.computing.net/answers/programming/running-batch-files-within-an-exe/19247.html