How can I achieve the following:
set host[0]=\\thisserver
set host[1]=\\thatserver
set host[2]=\\otherserver
set targethost = host[0]
call :do_stuff_with_each_host_in_turn
:do_stuff_with_each_host_in_turn
ping %targethost%
do stuff involving %targethost%
set targethost=%host%[next]
call :do_stuff_with_each_host_in_turn
popd
EXIT /B
My context is actually to carry out a series of PSexec (running commands remotely) on a long list of servers. I'd like to slim down the code by looping through the function and just use the name of the next server from the host array with each iteration of :do_stuff_with_each_host_in_turn
Many thanks!