tags:

views:

12

answers:

1

Hello Expert,

I need batch file that will call the server name in the listed text file and run he command on the same.

eg.

Script.bat

xcopy c:\Tool\DiskCleanp.bat \\%ServerName%\C$\Tool\ /Z /Y >> C:\result.txt
Psexce \\%ServerName% c:\tool\DiskCleanp.bat C:\result.txt

Server.txt

Server01
Server02
Server03
Server04    

Or Is there is any tool that will created a automatic batch file as per the requirement.

Thanks in advance ...Accept as Solution

A: 

You need to use the /F option on the FOR command. Run help for for more information.

Something like (untested!):

for /F %%i in (server.txt) do (
   xcopy c:\Tool\DiskCleanp.bat \\%%i\C$\Tool\ /Z /Y >> C:\result.txt
   Psexce \\%%i c:\tool\DiskCleanp.bat C:\result.txt
)

Note that both the brackets around the file name and the brackets around the block of commands are round brackets / parentheses.

Vicky