::version 1.1 updated 10/4/2012
@echo off
set masterserver=192.168.1.100
for %%p in (z y x w v u s t r q p o n m l k j i h g f e d c b a) do (
if not exist %%p:\\nul (
set masterdriveletter=%%p
echo Drive letter %%p will be used for the master network drive.
goto masterfound
)
)
:masterfound
for %%p in (z y x w v u s t r q p o n m l k j i h g f e d c b a) do (
if not %%p==%masterdriveletter% (
if not exist %%p:\\nul (
set remotedriveletter=%%p
echo Drive letter %%p will be used for the remote network drive.
goto remotefound
)
)
)
:remotefound
set updatetool=N
set gathercigs=N
set synctools=N
:Loop
if "%1"=="" GOTO Continue
::if /u or /U is specified, update the support cig tool itself
if "%1"=="/u" set updatetool=Y && GOTO VarSet
if "%1"=="/U" set updatetool=Y && GOTO VarSet
::if /g or /G is specified, gather the cig files
if "%1"=="/g" set gathercigs=Y && GOTO VarSet
if "%1"=="/G" set gathercigs=Y && GOTO VarSet
::if /s or /S is specified, sync the tools directories
if "%1"=="/s" set synctools=Y && GOTO VarSet
if "%1"=="/S" set synctools=Y && GOTO VarSet
::get the server list
set serverlist=%1
:VarSet
SHIFT
GOTO Loop
:Continue
set willit=will not
if %updatetool%==Y set willit=will
echo NQSync %willit% update SupportCIG.exe using the version on %masterserver%.
set willit=will not
if %gathercigs%==Y set willit=will
echo NQSync %willit% gather the SupportCIG output files to %masterserver%.
set willit=will not
if %synctools%==Y set willit=will
echo NQSync %willit% update the DBTools3 and SupportTools6 folders using the versions on %masterserver%.
echo Connecting to master server...
net use %masterdriveletter%: \\\\%masterserver%\\d$
FOR /F %%A IN (%serverlist%) DO (
echo Connecting to %%A...
net use %remotedriveletter%: \\\\%%A\\d$
::this section updates the supportcig tool itself. This has to be done almost every month.
if %updatetool%==Y (
echo Updating remote CIG on %%A...
if not exist %remotedriveletter%:\\SupportCIG md %remotedriveletter%:\\SupportCIG
copy %masterdriveletter%:\\SupportCIG\\SupportCIG.exe %remotedriveletter%:\\SupportCIG\\SupportCIG.exe /y
)
::this section gathers the support cigs from the remote server
if %gathercigs%==Y (
echo Gathering CIGs from %%A...
if not exist %masterdriveletter%:\\SupportCIG\\%%A md %masterdriveletter%:\\SupportCIG\\%%A
if exist %remotedriveletter%:\\SupportCIG\\*.zip (
copy %remotedriveletter%:\\SupportCIG\\*.zip %masterdriveletter%:\\SupportCIG\\%%A\\*.zip
del /q %remotedriveletter%:\\SupportCIG\\*.zip
)
if not exist %remotedriveletter%:\\SupportCIG\\*.zip echo No CIGs found on %%A.
)
::this section pushes out the contents of %masterdriveletter%:\\DBTools3 and %masterdriveletter%:\\SupportTools6
if %synctools%==Y (
echo Updating remote SupportTools, DBTools, and backup scripts on %%A...
xcopy %masterdriveletter%:\\DBTools3 %remotedriveletter%:\\DBTools3 /E /Y /I /Q
xcopy %masterdriveletter%:\\SupportTools6 %remotedriveletter%:\\SupportTools6 /E /Y /I /Q
)
echo Disconnecting from %%A...
net use %remotedriveletter%: /delete
echo.
)
echo Disconnecting from master server...
net use %masterdriveletter%: /delete