REM THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
REM ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
REM THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
REM PARTICULAR PURPOSE.

REM Copyright (C) 2004 Microsoft Corporation.  All Rights Reserved.

REM 
REM postimagefirstboot.cmd
REM 
REM Calls bootstrap.wsf to schedule the adbodgLauncher schedule task.
REM It can be extended to perform any additional environmental setup.

REM Schedules the launcher to run.
setlocal

set ADBODGROOT    =%SYSTEMDRIVE%\adbodg
set ADBODGSCRIPTS =%SYSTEMDRIVE%\adbodg\scripts
set ADBODGLOGS    =%SYSTEMDRIVE%\adbodg\logs


IF NOT EXIST %SYSTEMDRIVE%\adbodg         mkdir %SYSTEMDRIVE%\adbodg
IF NOT EXIST %SYSTEMDRIVE%\adbodg\scripts mkdir %SYSTEMDRIVE%\adbodg\scripts
IF NOT EXIST %SYSTEMDRIVE%\adbodg\logs    mkdir %SYSTEMDRIVE%\adbodg\logs

IF NOT "%1" == "" goto :%1

REM Put the credentials for the file server in the creds cache.
CMDKEY /add:%ADBODS_SRV% /user:%ADBODS_USER% /pass:%ADBODS_PWD%

REM Remove the ADBODS_USER and ADBODS_PWD from the registry.
setx ADBODS_USER "" /M
setx ADBODS_PWD "" /M


REM Call the script again writing out a log file.
call "%ALLUSERSPROFILE%\Start Menu\Programs\Startup\postimagefirstboot.cmd" BRANCHDC >> %SYSTEMDRIVE%\adbodg\logs\postimagefirstboot.log 2>&1

REM Don't run the script on next boot. This will cause a "batch file cannot be found" error.
del "%ALLUSERSPROFILE%\Start Menu\Programs\Startup\postimagefirstboot.cmd"

endlocal

goto :EOF



:BRANCHDC

REM ********************* BRANCHDC SETTINGS ********************************
REM ************************************************************************

date /T
time /T

REM Install Items not in the Image
net use \\%ADBODS_SRV%

REM Copy the scripts from the file server and setup the logs directory.
xcopy /E /Y \\%ADBODS_SRV%\adbodg\scripts\*.* %SYSTEMDRIVE%\adbodg\scripts\


REM BEGIN USER MODIFIABLE SECTION


REM TO DO:
REM Add any additional items for your environment.

REM The example below installs the support tools, the reskit tools, 
REM and DNS Server.  It then sets the DNS forwarders and NS Records Auto Creation.
REM Read below to find the expected paths.  SUPTOOLS.MSI is the install package for
REM the support tools.  rktools.msi is the install package for the reskit tools.
REM You may need to adjust the DNS forwarders.
REM Note that installing DNS Server requires access to the Windows Server 2003 installation file.
REM You may need to adjust the source path for the installation files to get the files pulled from
REM a network share.  Note the installDNSServer.txt isn't in the \\ADBODSServer by default.
REM You will need to copy it from the \adbranch03\ads directory into the \adbranch03\adbodg\scripts directory.
 
REM Install the support tools.
REM Msiexec /I \\%ADBODS_SRV%\adbodg\tools\SUPTOOLS.MSI /q

REM Add the support tools to the local path.
REM set PATH=%ProgramFiles%\Support Tools;%PATH%

REM Install the reskit.
REM Msiexec /I \\%ADBODS_SRV%\adbodg\tools\rktools.msi /q

REM Install DNS Server
REM sysocmgr /i:%SYSTEMROOT%\inf\sysoc.inf /u:%SYSTEMDRIVE%\adbodg\scripts\installDNSServer.txt

REM Set the DNS Forwarders
REM reg add HKLM\System\CurrentControlSet\Services\DNS\Parameters /v Forwarders /t REG_SZ /d "10.0.0.1 10.0.0.2" /f

REM Disable NS Records Auto Creation
REM reg add HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters /v DisableNSRecordsAutoCreation /t REG_DWORD /d "00000001" /f

REM Set the DNS tombstone lifetime to 15 days (reg key value is in seconds).
REM This is the amount of time before DNS server will delete from Active Directory a deleted record.
REM reg add HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters /v DsTombstoneInterval /t REG_DWORD /d "1296000" /f

REM Set the DirectoryPartitionAutoEnlistInterval to one hour (reg key value is in seconds).
REM reg add HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters /v DirectoryPartitionAutoEnlistInterval /t REG_DWORD /d "3600" /f


REM END USER MODIFIABLE SECTION


REM DO NOT EDIT BELOW.
REM Call bootstrap to have the machine set the scheduled task for
REM launcher now that we have the proper security context.

schtasks /DELETE /F /TN adbodgLauncher
cscript %SYSTEMDRIVE%\adbodg\scripts\bootstrap.wsf %COMPUTERNAME% %COMPUTERNAME%\Administrator %LOCALADMINPWD%


goto :EOF
