I need to have a batch file that copies files (8) in my local directory to either a list of machines on the network (hostname or IP) or have me prompt to enter the next hostname/ip
I’d prefer not to have to run the script over and over again to enter the next hostname/ip
I’ll also need to see the output for each system to make sure it connected correctly and copied successfully. Perhaps a “ready to process next?” after each machine?
I don’t know how to have a batch file does the equivalent of STDIN, so please forgive the ?STDIN? placeholder
So far, all I have is
net use S: \\?STDIN?\C$ /user:domain\myusername mypassword
copy %~file01.txt S:\%SystemRoot%\system32 /y
copy %~file02.txt S:\%SystemRoot%\system32 /y
copy %~file03.txt S:\%SystemRoot%\system32 /y
copy %~file04.txt S:\%SystemRoot%\system32 /y
copy %~file05.txt S:\%SystemRoot%\system32 /y
copy %~file06.txt S:\%SystemRoot%\system32 /y
copy %~file07.txt S:\%SystemRoot%\system32 /y
copy %~file08.txt S:\%SystemRoot%\system32 /y
net use :s /delete
do it again
You can prompt the user for input (and store it into an environment variable) with the
set /pcommand:You can loop by using a label and jump to it. You should offer a way to exit, though:
If you don’t want to enter each host name individually you can also loop over the arguments to the batch file:
You can can call it as follows, then:
HTH