Reputation: 1
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
Psexec \\%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
Upvotes: 0
Views: 3548
Reputation: 13244
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
Psexec \\%%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.
Upvotes: 1