Skip navigation

A script for file server fail over.

David A. Stewart brings us File_Server_Fail-over.cmd.

David A. Stewart brings us File_Server_Fail-over.cmd, which contains:

REM Purpose:  and Bring the Backup System Online impersonating the Primary
REM Operating System
@ECHO OFF
REM ******************************************************************
REM Name: File_Server_Fail-over.cmd
REM Author: David A. Stewart [email protected]
REM Purpose: To Replicate File Service Configuration to a Back-up File Server
REM Purpose:  and Bring the Backup System Online impersonating the Primary
REM Operating System: NT4 and Above
REM Dependencies: NOW.EXE from the W2K Reskit
REM Dependencies: CHOICE.EXE from the W2K Reskit
REM Dependencies: REGDMP.EXE from the W2K Reskit
REM Dependencies: REGINI.EXE from the W2K Reskit
REM Dependencies: 
REM Version: 2.22
REM Creation Date: 5-27-2003
REM Last Modified: 8-11-2003
REM Additional Information: 
REM 
REM 
REM ******************************************************************
@TITLE File Server Fail-over Script
GOTO START
REM This is Organizational Workspace


REM End of Organizational Workspace

:START
SETLOCAL
REM CScript //H:CScript

:Set_Variables
SET SourceServerName=
SET FailoverServerName=
SET Chronstamp=
SET OSType=
SET VER=
SET RunFunction=
SET OnlineState=
SET SourceServerIP=
SET CURRENTPATH=
SET ShareLogFile=
SET ActionLogFile=
SET FailoverServerName=
SET REPLICATE_VARIABLE=
SET RegDmpState=
SET RegIniState=
SET Quit=
SET RunAs=x
:LOGIC_SECTION
:TEST OS Type
IF NOT "%OS%"

"Windows_NT" GOTO OSERROREND SET OSType=Windows_NT FOR /F "Delims=~ Tokens=1*" %%a IN ('VER') DO SET VER=%%a IF "%VER%"

"Microsoft Windows 2000 \[Version 5.00.2195\]" SET OSType=W2K IF "%VER%"

"Windows NT Version 4.0 " SET OSType=NT4 ECHO OS Type is %OSType% ECHO Version is %VER% IF NOT EXIST "NOW.EXE" ECHO MISSING REQUIRED FILE NOW.EXE &PAUSE&GOTO :EOF IF NOT EXIST "CHOICE.EXE" ECHO MISSING REQUIRED FILE CHOICE.EXE &PAUSE&GOTO :EOF IF NOT EXIST "REGDMP.EXE" ECHO MISSING REQUIRED FILE REGDMP.EXE &PAUSE&GOTO :EOF IF NOT EXIST "REGINI.EXE" ECHO MISSING REQUIRED FILE REGINI.EXE &PAUSE&GOTO :EOF :WRITE_ACCESS_TEST CALL :WINDOWHEADER ECHO testdump>testdumpfileç.txt IF NOT EXIST testdumpfileç.txt ECHO. &ECHO WRITE ACCESS DENIED!! &ECHO You Must Have Read/Write Access to the current directory to run this script. &ECHO. &GOTO BOTTOM IF EXIST testdumpfileç.txt DEL testdumpfileç.txt :RUN_AS CALL :WINDOWHEADER ECHO You are currently running this script as user account %USERDOMAIN%\%USERNAME% ECHO. ECHO Do you: ECHO. ECHO 1. Want to Run this script under the security context of another account? ECHO. ECHO 2. Continue with security level of account %USERDOMAIN%\%USERNAME% ? ECHO. CHOICE /C:12 "Pick " IF %ERRORLEVEL%

2 GOTO START_TIME_AND_DATE SET RunAs=1 ECHO. ECHO. ECHO Enter the new account you want to "Run As" SET /P NewDomain=Local Machine or Domain Name of the account: SET /P NewName=Account Name: ECHO. :START_TIME_AND_DATE FOR /F "Tokens=1*" %%f IN ('TIME /T') DO ( FOR /F "Delims=: Tokens=1-2" %%y in ('ECHO %%f') DO SET StartTime=%%y-%%z ) FOR /F "Tokens=1,2*" %%f IN ('DATE /T') DO ( FOR /F "Tokens=1-3 Delims=/" %%x IN ('ECHO %%g') DO SET StartDate=%%x-%%y-%%z ) CALL :CHRONSTAMP GOTO DESIRED_FUNCTION_QUESTION :CHRONSTAMP FOR /F "Tokens=1-5" %%a IN ('NOW.EXE') DO SET Chronstamp=%%a_%%b_%%c_%%d_%%e FOR /F "Delims=: Tokens=1-3" %%a IN ('ECHO %Chronstamp%') DO SET Chronstamp=%%a_%%b_%%c FOR /F "Delims=_ Tokens=1-7" %%a IN ('ECHO %Chronstamp%') DO SET Chronstamp=%%b_%%c_%%g____%%d_%%e_%%f GOTO :EOF :DESIRED_FUNCTION_QUESTION FOR /F "Tokens=*" %%a IN ('CD') DO SET CURRENTPATH=%%a IF NOT EXIST "%CURRENTPATH%\log_files\." MD "log_files" SET ActionLogFile="%CURRENTPATH%\log_files\Action_log_file____%Chronstamp%.txt" IF NOT EXIST %ActionLogFile% ECHO Created %StartDate% at %StartTime%>%ActionLogFile% CALL :WINDOWHEADER TIME /T>NUL ECHO Do you: ECHO. ECHO 1. Want to CAPTURE file share configuration from a server to a RECOVERY FILE? ECHO. ECHO 2. Perform a RESTORE to a Fail-over server from a Recovery File? ECHO. ECHO 3. REPLICATE shares to a Fail-over Server? ECHO. ECHO 4. Quit? ECHO. CHOICE /C:1234 "Pick " IF %ERRORLEVEL%

1 SET RunFunction=capture IF %ERRORLEVEL%

2 SET RunFunction=restore IF %ERRORLEVEL%

3 SET RunFunction=replicate IF %ERRORLEVEL%

4 GOTO :EOF IF "%RunFunction%"

"capture" GOTO CAPTURE_FILE_SERVER_INFO IF "%RunFunction%"

"restore" GOTO RESTORE_FILE_SERVER_INFO IF "%RunFunction%"

"replicate" GOTO REPLICATE_FILE_SERVER_INFO GOTO DESIRED_FUNCTION_QUESTION :ACTION :CAPTURE_FILE_SERVER_INFO REM Get the Name of the Target Server to Capture CALL :WINDOWHEADER SET /P SourceServerName=What is the name of the Source Server you want to capture ? : FOR /F "Delims=\\ Tokens=1*" %%a in ('ECHO %SourceServerName%') DO SET SourceServerName=%%a IF /I NOT "%SourceServerName%"

"%COMPUTERNAME%" GOTO END_WARNING_NOTICE :WARNING_NOTICE CLS CALL :WINDOWHEADER ECHO WARNING: Running this script from a local drive on the source server ECHO will prevent access to the capture file in the event of failure ECHO of the storage system on the source server. ECHO. ECHO. ECHO Do you: ECHO. ECHO 1. Want to continue? ECHO. ECHO 2. Quit? ECHO. CHOICE /C:12 "Pick " IF %ERRORLEVEL%

1 GOTO END_WARNING_NOTICE IF %ERRORLEVEL%

2 SET Quit=1 :END_WARNING_NOTICE IF "%Quit%"

"1" ECHO Quiting.... & GOTO :EOF @TITLE Gathering File Share and IP Information from Server \[ %SourceServerName% \] CALL :WINDOWHEADER ECHO Searching for Server: %SourceServerName%... ECHO. REM Checking Server Online Status SET OnlineState=OFFLINE FOR /F "Skip=3 Delims=:= Tokens=2" %%a in ('PING %SourceServerName%') DO ( IF "%%a"

" bytes" SET OnlineState=ONLINE ) IF "%OnlineState%"

"ONLINE" ECHO %SourceServerName% is %OnlineState% CALL :CHRONSTAMP ECHO.>>%ActionLogFile% ECHO.>>%ActionLogFile% IF "%RunAs%"

"1" ECHO %Chronstamp% User is running under the security context of %NewDomain%\%NewName%>>%ActionLogFile% IF NOT "%RunAs%"

"1" ECHO %Chronstamp% User is running under the security context of %USERDOMAIN%\%USERNAME%>>%ActionLogFile% ECHO %Chronstamp% User selected a source server file share configuration capture>>%ActionLogFile% ECHO %Chronstamp% Source Server Name: %SourceServerName%>>%ActionLogFile% ECHO %Chronstamp% Source Server's Online State: %OnlineState%>>%ActionLogFile% IF NOT "%OnlineState%"

"ONLINE" ECHO The server %SourceServerName% is Unreachable, Quitting. &GOTO :DESIRED_FUNCTION_QUESTION REM Find Source Server's Primary IP Address FOR /F "Delims=\[\] Tokens=2 Skip=1" %%a IN ('PING -n 1 %SourceServerName%') DO SET SourceServerIP=%%a ECHO The IP for %SourceServerName% is %SourceServerIP% ECHO. ECHO %Chronstamp% The IP for %SourceServerName% is %SourceServerIP%>>%ActionLogFile% CALL :CHRONSTAMP IF NOT EXIST "%CURRENTPATH%\recovery_files\." MD "recovery_files" &ECHO %Chronstamp% Created missing recovery_files directory>>%ActionLogFile% SET ShareLogFile="%CURRENTPATH%\recovery_files\%SourceServerName%_ShareList_%Chronstamp%.TXT" REM ECHO ShareLogFile=%ShareLogFile% ECHO %Chronstamp% ShareLogFile=%ShareLogFile%>>%ActionLogFile% ECHO. ECHO Processing, Please wait.... ECHO. ECHO %Chronstamp% Begining configuration collection>>%ActionLogFile% REM Write the source servers configuration to a configuration capture file using the REGDMP.EXE command. SET RegDmpState=x IF "%RunAs%"

"1" GOTO REGDMP_RUNAS IF /I NOT "%SourceServerName%"

"%COMPUTERNAME%" GOTO REGDMP_REMOTE REGDMP.EXE "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares">%ShareLogFile% SET RegDmpState=%ERRORLEVEL% GOTO REGDMP_END :REGDMP_REMOTE REGDMP.EXE -m \\%SourceServerName% "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares">%ShareLogFile% SET RegDmpState=%ERRORLEVEL% :REGDMP_END CALL :CHRONSTAMP IF NOT "%RegDmpState%"

"0" ECHO There was a problem with the capture. Verify that you have proper access and permissions to perform a remote registry read on the target server.&ECHO %Chronstamp% There was a problem with the capture. Verify that you have proper access and permissions to perform a remote registry read on the target server.>>%ActionLogFile%&DEL %ShareLogFile% IF "%RegDmpState%"

"0" ECHO Capture completed successfully.&ECHO %Chronstamp% Capture completed successfully.>>%ActionLogFile% GOTO BOTTOM :REGDMP_RUNAS ECHO @ECHO OFF>RUNASBAT.BAT ECHO SET RegDmpState=X>>RUNASBAT.BAT ECHO IF /I NOT "%%SourceServerName%%"

"%%COMPUTERNAME%%" GOTO REGDMP_REMOTE>>RUNASBAT.BAT ECHO REGDMP.EXE "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares"^>%ShareLogFile%>>RUNASBAT.BAT ECHO SET RegDmpState=%%ERRORLEVEL%%>>RUNASBAT.BAT ECHO GOTO REGDMP_END>>RUNASBAT.BAT ECHO :REGDMP_REMOTE>>RUNASBAT.BAT ECHO REGDMP.EXE -m \\%SourceServerName% "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares"^>^>%ShareLogFile%>>RUNASBAT.BAT ECHO SET RegDmpState=%%ERRORLEVEL%%>>RUNASBAT.BAT ECHO :REGDMP_END>>RUNASBAT.BAT REM ECHO SET RegDmpState=%%ERRORLEVEL%%>>RUNASBAT.BAT ECHO CALL :CHRONSTAMP>>RUNASBAT.BAT ECHO IF NOT "%%RegDmpState%%"

"0" ECHO There was a problem with the capture. Verify that you have proper access and permissions to perform a remote registry read on the target server.^&ECHO %%Chronstamp%% There was a problem with the capture. Verify that you have proper access and permissions to perform a remote registry read on the target server.^>^>%ActionLogFile% ^&DEL %ShareLogFile%>>RUNASBAT.BAT ECHO IF "%%RegDmpState%%"

"0" ECHO Capture completed successfully.^&ECHO %%Chronstamp%% Capture completed successfully.^>^>%ActionLogFile%>>RUNASBAT.BAT ECHO PAUSE>>RUNASBAT.BAT ECHO :CHRONSTAMP>>RUNASBAT.BAT ECHO FOR /F "Tokens=1-5" %%%%a IN ('NOW.EXE') DO SET Chronstamp=%%%%a_%%%%b_%%%%c_%%%%d_%%%%e>>RUNASBAT.BAT ECHO FOR /F "Delims=: Tokens=1-3" %%%%a IN ('ECHO %%Chronstamp%%') DO SET Chronstamp=%%%%a_%%%%b_%%%%c>>RUNASBAT.BAT ECHO FOR /F "Delims=_ Tokens=1-7" %%%%a IN ('ECHO %%Chronstamp%%') DO SET Chronstamp=%%%%b_%%%%c_%%%%g____%%%%d_%%%%e_%%%%f>>RUNASBAT.BAT ECHO GOTO :EOF>>RUNASBAT.BAT RUNAS /ENV /NETONLY /USER:%NewDomain%\%NewName% "RUNASBAT.BAT" ECHO. ECHO Once activity has completed in the pop-up window PAUSE GOTO BOTTOM :RESTORE_FILE_SERVER_INFO REM Get the Name of the Fail-over Server to Target a Restore CALL :WINDOWHEADER SET /P FailoverServerName=What is the name of the Fail-over Server you want to Target a Restore ? : FOR /F "Delims=\\ Tokens=1*" %%a in ('ECHO %FailoverServerName%') DO SET FailoverServerName=%%a @TITLE Gathering File Share and IP Information from Server \[ %FailoverServerName% \] CALL :WINDOWHEADER ECHO Searching for Server: %FailoverServerName%... ECHO. REM Checking Server Online Status SET OnlineState=OFFLINE FOR /F "Skip=3 Delims=:= Tokens=2" %%a in ('PING %FailoverServerName%') DO ( IF "%%a"

" bytes" SET OnlineState=ONLINE ) IF "%OnlineState%"

"ONLINE" ECHO %FailoverServerName% is %OnlineState% CALL :CHRONSTAMP IF "%RunAs%"

"1" ECHO %Chronstamp% User is running under the security context of %NewDomain%\%NewName%>>%ActionLogFile% IF NOT "%RunAs%"

"1" ECHO %Chronstamp% User is running under the security context of %USERDOMAIN%\%USERNAME%>>%ActionLogFile% ECHO %Chronstamp% User selected a Fail-over Server to Target a Restore>>%ActionLogFile% ECHO %Chronstamp% Target Server Name: %FailoverServerName%>>%ActionLogFile% ECHO %Chronstamp% Target Server's Online State: %OnlineState%>>%ActionLogFile% IF NOT "%OnlineState%"

"ONLINE" ECHO The server %FailoverServerName% is Unreachable, Quitting. &GOTO :DESIRED_FUNCTION_QUESTION REM Find Restore Server's Primary IP Address FOR /F "Delims=\[\] Tokens=2 Skip=1" %%a IN ('PING -n 1 %FailoverServerName%') DO SET RestoreServerIP=%%a ECHO The IP for %FailoverServerName% is %RestoreServerIP% ECHO. CALL :CHRONSTAMP ECHO %Chronstamp% The IP for %FailoverServerName% is %RestoreServerIP%>>%ActionLogFile% :VERIFY_RESTORE_LOG_FILE_NAME IF "%REPLICATE_VARIABLE%"

"YES" GOTO BEGIN_RESTORE_PROCESS IF \["%ShareLogFile%"\]

\[""\] SET /P ShareLogFile=Enter the EXACT \\path\name of the Restore Log File : IF \["%ShareLogFile%"\]

\[""\] GOTO VERIFY_RESTORE_LOG_FILE_NAME SET ShareLogFile="%ShareLogFile%" ECHO. ECHO. ECHO The name of the Restore Log File is : %ShareLogFile% ECHO. CHOICE "Is this correct " IF %ERRORLEVEL%

1 GOTO BEGIN_RESTORE_PROCESS IF %ERRORLEVEL%

2 SET ShareLogFile= IF %ERRORLEVEL%

2 GOTO VERIFY_RESTORE_LOG_FILE_NAME GOTO VERIFY_RESTORE_LOG_FILE_NAME :BEGIN_RESTORE_PROCESS REM ** Note this will not work unless Identical drive letters and directory structures are present on the fail-over system ** @TITLE Restoring File Shares to the Failover Server \[ %FailoverServerName% \] ECHO %Chronstamp% Restore Log File: %ShareLogFile%>>%ActionLogFile% CALL :WINDOWHEADER ECHO. ECHO Beginning File Share Replication from log file... ECHO. REM Create Shares on the Fail-over Server using REGINI.EXE CALL :CHRONSTAMP ECHO %Chronstamp% Trying to Create Shares on the Fail-over Server>>%ActionLogFile% SET RegIniState=x IF /I "%FailoverServerName%"

"%COMPUTERNAME%" GOTO PERFORM_ON_SELF IF "%RunAs%"

"1" GOTO REGINI_RUNAS CALL :WINDOWHEADER ECHO. CHOICE "Do you want to remove any existing file shares stored in the registry of the target server before entering the new shares " IF \[%ERRORLEVEL%\]

\[1\] REG DELETE HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares \\%FailoverServerName% /FORCE ECHO. REGINI.EXE -m "\\%FailoverServerName%" %ShareLogFile% SET RegIniState=%ERRORLEVEL% CALL :CHRONSTAMP IF NOT "%RegIniState%"

"0" ECHO *** There was a problem with the restore. *** Verify that you have proper access and permissions to perform a remote registry write on the target server.&ECHO %Chronstamp% *** There was a problem with the restore. *** Verify that you have proper access and permissions to perform a remote registry write on the targeted server.>>%ActionLogFile% &GOTO BOTTOM IF "%RegIniState%"

"0" ECHO Done replicating the Share log, %ShareLogFile%, to server, "%FailoverServerName%"&ECHO %Chronstamp% Done replicating the Share log, %ShareLogFile%, to server, "%FailoverServerName%">>%ActionLogFile% ECHO. ECHO. ECHO NOTE: Once ALL the drives(or LUNS) are functional on the Fail-over server, ECHO You MUST Restart the server service or Reboot %FailoverServerName% ECHO to activate the file share replication changes. Shares will not be ECHO available until this occurs. ECHO. ECHO. GOTO BOTTOM :REGINI_RUNAS IF EXIST "RUNASBAT.BAT" DEL "RUNASBAT.BAT" ECHO @ECHO OFF>RUNASBAT.BAT ECHO SET RegIniState=X>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO CHOICE "Do you want to remove any existing file shares stored in the registry of the target server before entering the new shares ">>RUNASBAT.BAT ECHO IF \[%%ERRORLEVEL%%\]

\[1\] REG DELETE HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares \\%%FailoverServerName%% /FORCE>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO REGINI.EXE -m "\\%FailoverServerName%" %ShareLogFile%>>RUNASBAT.BAT ECHO SET RegIniState=%%ERRORLEVEL%%>>RUNASBAT.BAT ECHO CALL :CHRONSTAMP>>RUNASBAT.BAT ECHO IF NOT "%%RegIniState%%"

"0" ECHO *** There was a problem with the restore. *** Verify that you have proper access and permissions to perform a remote registry write on the target server.^&ECHO %%Chronstamp%% *** There was a problem with the restore. *** Verify that you have proper access and permissions to perform a remote registry write on the targeted server.^>^>%ActionLogFile% ^&GOTO BOTTOM>>RUNASBAT.BAT ECHO IF "%%RegIniState%%"

"0" ECHO Done replicating the Share log, %ShareLogFile%, to server, "%FailoverServerName%"^&ECHO %%Chronstamp%% Done replicating the Share log, %ShareLogFile%, to server, "%FailoverServerName%"^>^>%ActionLogFile%>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO ECHO NOTE: Once ALL the drives(or LUNS) are functional on the Fail-over server,>>RUNASBAT.BAT ECHO ECHO You MUST Restart the server service or Reboot %FailoverServerName%>>RUNASBAT.BAT ECHO ECHO to activate the file share replication changes. Shares will not be>>RUNASBAT.BAT ECHO ECHO available until this occurs.>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO :BOTTOM>>RUNASBAT.BAT ECHO PAUSE>>RUNASBAT.BAT ECHO GOTO :EOF>>RUNASBAT.BAT ECHO :CHRONSTAMP>>RUNASBAT.BAT ECHO FOR /F "Tokens=1-5" %%%%a IN ('NOW.EXE') DO SET Chronstamp=%%%%a_%%%%b_%%%%c_%%%%d_%%%%e>>RUNASBAT.BAT ECHO FOR /F "Delims=: Tokens=1-3" %%%%a IN ('ECHO %%Chronstamp%%') DO SET Chronstamp=%%%%a_%%%%b_%%%%c>>RUNASBAT.BAT ECHO FOR /F "Delims=_ Tokens=1-7" %%%%a IN ('ECHO %%Chronstamp%%') DO SET Chronstamp=%%%%b_%%%%c_%%%%g____%%%%d_%%%%e_%%%%f>>RUNASBAT.BAT ECHO GOTO :EOF>>RUNASBAT.BAT RUNAS /ENV /NETONLY /USER:%NewDomain%\%NewName% "RUNASBAT.BAT" ECHO Once activity has completed in the pop-up window PAUSE GOTO BOTTOM :PERFORM_ON_SELF IF "%RunAs%"

"1" GOTO REGINI_PERFORM_ON_SELF_RUNAS ECHO. CHOICE "Do you want to remove any existing file shares stored in the registry of the target server before entering the new shares " IF \[%ERRORLEVEL%\]

\[1\] REG DELETE HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares /FORCE ECHO. REGINI.EXE %ShareLogFile% CALL :WINDOWHEADER SET RegIniState=%ERRORLEVEL% CALL :CHRONSTAMP IF NOT "%RegIniState%"

"0" ECHO *** There was a problem with the restore. *** Verify that you have proper access and permissions to perform a remote registry write on the target server.&ECHO %Chronstamp% *** There was a problem with the restore. *** Verify that you have proper access and permissions to perform a remote registry write on the targeted server.>>%ActionLogFile% &GOTO BOTTOM IF "%RegIniState%"

"0" ECHO Done replicating the Share log, %ShareLogFile%, to server, "%FailoverServerName%"&ECHO %Chronstamp% Done replicating the Share log, %ShareLogFile%, to server, "%FailoverServerName%">>%ActionLogFile% ECHO. ECHO. ECHO NOTE: Once ALL the drives(or LUNS) are functional on the Fail-over server, ECHO You MUST Restart the server service or Reboot %FailoverServerName% ECHO to activate the file share replication changes. Shares will not be ECHO available until this occurs. ECHO. ECHO. GOTO BOTTOM :REGINI_PERFORM_ON_SELF_RUNAS IF EXIST "RUNASBAT.BAT" DEL "RUNASBAT.BAT" ECHO @ECHO OFF>RUNASBAT.BAT ECHO SET RegIniState=x>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO CHOICE "Do you want to remove any existing file shares stored in the registry of the target server before entering the new shares ">>RUNASBAT.BAT ECHO IF \[%%ERRORLEVEL%%\]

\[1\] REG DELETE HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\Shares /FORCE>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO REGINI.EXE %ShareLogFile%>>RUNASBAT.BAT ECHO SET RegIniState=%%ERRORLEVEL%%>>RUNASBAT.BAT ECHO CALL :CHRONSTAMP>>RUNASBAT.BAT ECHO IF NOT "%%RegIniState%%"

"0" ECHO *** There was a problem with the restore. *** Verify that you have proper access and permissions to perform a remote registry write on the target server.^&ECHO %%Chronstamp%% *** There was a problem with the restore. *** Verify that you have proper access and permissions to perform a remote registry write on the targeted server.^>^>%ActionLogFile% ^&GOTO BOTTOM>>RUNASBAT.BAT ECHO IF "%%RegIniState%%"

"0" ECHO Done replicating the Share log, %ShareLogFile%, to server, "%FailoverServerName%"^&ECHO %%Chronstamp%% Done replicating the Share log, %ShareLogFile%, to server, "%FailoverServerName%"^>^>%ActionLogFile%>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO ECHO NOTE: Once ALL the drives(or LUNS) are functional on the Fail-over server,>>RUNASBAT.BAT ECHO ECHO You MUST Restart the server service or Reboot %FailoverServerName%>>RUNASBAT.BAT ECHO ECHO to activate the file share replication changes. Shares will not be>>RUNASBAT.BAT ECHO ECHO available until this occurs.>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO ECHO.>>RUNASBAT.BAT ECHO :BOTTOM>>RUNASBAT.BAT ECHO PAUSE>>RUNASBAT.BAT ECHO GOTO :EOF>>RUNASBAT.BAT ECHO :CHRONSTAMP>>RUNASBAT.BAT ECHO FOR /F "Tokens=1-5" %%%%a IN ('NOW.EXE') DO SET Chronstamp=%%%%a_%%%%b_%%%%c_%%%%d_%%%%e>>RUNASBAT.BAT ECHO FOR /F "Delims=: Tokens=1-3" %%%%a IN ('ECHO %%Chronstamp%%') DO SET Chronstamp=%%%%a_%%%%b_%%%%c>>RUNASBAT.BAT ECHO FOR /F "Delims=_ Tokens=1-7" %%%%a IN ('ECHO %%Chronstamp%%') DO SET Chronstamp=%%%%b_%%%%c_%%%%g____%%%%d_%%%%e_%%%%f>>RUNASBAT.BAT ECHO GOTO :EOF>>RUNASBAT.BAT RUNAS /ENV /NETONLY /USER:%NewDomain%\%NewName% "RUNASBAT.BAT" ECHO Once activity has completed in the pop-up window GOTO BOTTOM :REPLICATE_FILE_SERVER_INFO REM ** Note this will note work unless Identical drive letters and directory structures are present on the fail-over system ** CALL :CHRONSTAMP ECHO %Chronstamp% User has selected to replicate file share configuration to a second server.>>%ActionLogFile% SET REPLICATE_VARIABLE=YES CALL :CAPTURE_FILE_SERVER_INFO IF "%Quit%"

"1" GOTO BOTTOM IF "%RunAs%"

"1" CALL :RUN_AS_TARGET GOTO RESTORE_FILE_SERVER_INFO

:SUB_ROUTINES :RUN_AS_TARGET CALL :WINDOWHEADER SET QUICKVAR= ECHO You are currently running this script as user account %NewDomain%\%NewName% ECHO. ECHO When connecting to the Target Relication Server, Do you: ECHO. ECHO 1. Want to Run this script under the security context of another account ? ECHO. ECHO 2. Continue with security level of account %NewDomain%\%NewName% ? ECHO. ECHO 3. Change to the security level of account %USERDOMAIN%\%USERNAME% ? ECHO. CHOICE /C:123 "Pick " SET QUICKVAR=%ERRORLEVEL% IF \[%QUICKVAR%\]\[2\] GOTO :EOF IF \[%QUICKVAR%\]

\[3\] SET RunAs=0 IF \[%QUICKVAR%\]

\[3\] GOTO :EOF ECHO. ECHO. ECHO Enter the new account you want to "Run As" SET /P NewDomain=Local Machine or Domain Name of the account: SET /P NewName=Account Name: ECHO. GOTO :EOF :WINDOWHEADER CLS ECHO ############################################################ ECHO #### File Server Fail-over Script #### ECHO #### #### ECHO #### Author: David A. Stewart #### ECHO #### Date: 7-23-2003 #### ECHO #### Version: 2.21 #### ECHO #### #### ECHO #### #### ECHO ############################################################ ECHO. ECHO. ECHO. GOTO :EOF :OSERROREND ECHO This is not a compatible OS version. This script should be run from W2K and above systems. PAUSE GOTO :EOF :BOTTOM IF NOT "%REPLICATE_VARIABLE%"=="YES" PAUSE IF EXIST "RUNASBAT.BAT" DEL "RUNASBAT.BAT" ENDLOCAL GOTO :EOF

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish