Jump to content

Recommended Posts

Posted

Hi everyone

 

Ive written a small batch file that connects to remote computers, lists the folders in Docments and Settings folder and outputs the results to a text file. The problem is that only results from the last remote computer in the file is output to the text file. I want to have all the computers reults written to the text file. Batch file is as follows:-

 

for /f %%i in (c:\computers.txt) do dir /ad "\\%%i\c$\Documents and Settings" > results.txt

 

I think i need a for next loop

 

Any help and guidance would be appreciated

 

Regards

Barry Stone

Posted (edited)

Not sure if its exactly what you wanted, but using >> will append to the file.

 

e.g for /f %%i in (c:\computers.txt) do dir /ad "\\%%i\c$\Documents and Settings" >> results.txt

 

Alternatively if you want a file for each computer, perhaps this?

 

for /f %%i in (c:\computers.txt) do dir /ad "\\%%i\c$\Documents and Settings" > "results %%i.txt"

Edited by andy_b
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...