mixty
By: a guest | Nov 4th, 2009 | Syntax:
DOS | Size: 2.15 KB | Hits: 131 | Expires: Never
:: ****************************************************************
:: Batch: Remote File Existence Check
:: Creation Date: 4th Nov 2009
:: By: mixty dot hk at gmail dot com
:: Supported OS: 2K/XP/Vista/7
:
: Description: This batch checks a specified list of computers for
:: specified files. It outputs a specified .CSV file
:: containing "Computer Name","Result"
:: "Result" can be any of the following:
:: "Yes" -- All files are found
:
: "No" -- One/all of the file is/are not found
:: "Error" -- Error mapping network drive
:: Ensure you're running this as a domain administrator
:: or a user with enough access right to any specified
:: computers' admin$ share.
:: Usage: See below
:: ****************************************************************
:: specify a file containing computer (names or IP), one on each line
set compFile=c:\computers.txt
:: specify output file
set output=c:\results.csv
:: specify error log
:: specify a drive to be mapped (must be unused locally)
:
: specify 2 files to check for existence
:: specify the remote share to be connected
:: e.g. where the files to be checked reside
set share=admin$\system32
:
: specify any additional parameter for NET USE (default: empty)
type nul>%error%
echo "Computer Name","Results">"
%output%"
net use
%tempDrive% /
del /y>>
nul 2>>&1
echo.&echo :
: Currently checking %%i&echo.
net use
%tempDrive% \\
%%i\
%share% %anyParameter%>>
nul 2>>
%error%
echo "
%%i","Error">>"
%output%"
echo :
: There was an error accessing "%%i" >>%error%
echo "
%%i","Yes">>"
%output%"
echo "
%%i","No">>"
%output%"
)
echo "
%%i","No">>"
%output%"
)
)
net use
%tempDrive% /
del /y>>
nul 2>>&1
)