Create a batch file like (say check.bat
):
@echo off
set list=server1 server2 server3 server4 serverN
for %%s in (%list%) do (
echo Logging in to %%s
net use \\%%s\shared /user:mydomain\myuser password
echo Checking file existence on %%s
if exist \\%%s\shared\file.txt (
echo File exist on %%s
) else (
echo File does NOT exist on %%s
)
echo Logging out
net use \\%%s\shared /delete
)
For details on the net use
commands, see the accepted answer for question Mapping a network drive without hardcoding a drive letter in a batch file.