@echo off

::Check for arguments
if "%1"=="" goto noparameter
if "%2"=="" goto noparameter
if "%3"=="" goto noparameter
if "%4"=="" goto noparameter

::Restart IIS server, so that dlls can be overwritten
echo "Restarting IIS Server..."
iisreset

::Update database
osql -S %1 -d %2 -U %3 -P %4 -i Scriptbcmap102.sql

::Start copying files
echo "Copying Files..."

mkdir ..\BackupSCA22_200813_Studio

regsvr32 /u /s ..\bin\BBCA20XMLGenerator.dll
move  ..\bin\BBCA20XMLGenerator.dll ..\BackupSCA22_200813_Studio\.
copy bin\BBCA20XMLGenerator.dll ..\bin\.
regsvr32 /s ..\bin\BBCA20XMLGenerator.dll

regsvr32 /u /s ..\bin\BBCA20ImpExp.dll
move  ..\bin\BBCA20ImpExp.dll ..\BackupSCA22_200813_Studio\.
copy bin\BBCA20ImpExp.dll ..\bin\.
regsvr32 /s ..\bin\BBCA20ImpExp.dll

move  ..\bin\SCA22.sql ..\BackupSCA22_200813_Studio\.
copy bin\SCA22.sql ..\bin\.

regsvr32 /u /s ..\..\shared\BBCA20ScriptGenerator.dll
move  ..\..\shared\BBCA20ScriptGenerator.dll ..\BackupSCA22_200813_Studio\.
copy bin\BBCA20ScriptGenerator.dll ..\..\shared\.
regsvr32 /s ..\..\shared\BBCA20ScriptGenerator.dll

regsvr32 /u /s ..\..\shared\BBCA20Convdll.dll
move  ..\..\shared\BBCA20Convdll.dll ..\BackupSCA22_200813_Studio\.
copy bin\BBCA20Convdll.dll ..\..\shared\.
regsvr32 /s ..\..\shared\BBCA20Convdll.dll

move  ..\bin\bbca20recoding.exe ..\BackupSCA22_200813_Studio\.
copy bin\bbca20recoding.exe ..\bin\.

move ..\home\ConversionObjects\showmappingobjects.asp  ..\BackupSCA22_200813_Studio\.
copy home\ConversionObjects\showmappingobjects.asp ..\home\ConversionObjects\.

move ..\home\ConversionObjects\copytocurrentVRC.asp  ..\BackupSCA22_200813_Studio\.
copy home\ConversionObjects\copytocurrentVRC.asp ..\home\ConversionObjects\.

move ..\home\ConversionObjects\ShowMOControl.asp  ..\BackupSCA22_200813_Studio\.
copy home\ConversionObjects\ShowMOControl.asp ..\home\ConversionObjects\.

move ..\home\ConversionObjects\ShowLGMOControl.asp  ..\BackupSCA22_200813_Studio\.
copy home\ConversionObjects\ShowLGMOControl.asp ..\home\ConversionObjects\.

move ..\home\ConversionObjects\CheckInProgress.asp  ..\BackupSCA22_200813_Studio\.
copy home\ConversionObjects\CheckInProgress.asp ..\home\ConversionObjects\.

move ..\home\ConversionBuild\UpdateSetAndBecsInfo.asp  ..\BackupSCA22_200813_Studio\.
copy home\ConversionBuild\UpdateSetAndBecsInfo.asp ..\home\ConversionBuild\.

move ..\home\ConversionBuild\SettingInfo.asp  ..\BackupSCA22_200813_Studio\.
copy home\ConversionBuild\SettingInfo.asp ..\home\ConversionBuild\.

move ..\home\ConversionBuild\Done.asp  ..\BackupSCA22_200813_Studio\.
copy home\ConversionBuild\Done.asp ..\home\ConversionBuild\.

move ..\home\DDImport_Legacy\MDcreator.asp  ..\BackupSCA22_200813_Studio\.
copy home\DDImport_Legacy\MDcreator.asp ..\home\DDImport_Legacy\.

move ..\home\DDImport_Legacy\querybldr.asp  ..\BackupSCA22_200813_Studio\.
copy home\DDImport_Legacy\querybldr.asp ..\home\DDImport_Legacy\.

move ..\home\Applications\filesperapp.asp  ..\BackupSCA22_200813_Studio\.
copy home\Applications\filesperapp.asp ..\home\Applications\.

move ..\home\DDImport_Baan\iddwone.asp  ..\BackupSCA22_200813_Studio\.
copy home\DDImport_Baan\iddwone.asp ..\home\DDImport_Baan\.

copy home\OnlineHelp\enduser\ImportBaanApplications.htm ..\home\OnlineHelp\enduser\.

move ..\home\library\controls\PrjMappingControl.CAB ..\BackupSCA22_200813_Studio\.
copy home\library\controls\PrjMappingControl.CAB ..\home\library\controls\.

move ..\home\library\controls\BBCALGYMappingControl.CAB ..\BackupSCA22_200813_Studio\.
copy home\library\controls\BBCALGYMappingControl.CAB ..\home\library\controls\.

echo "Finished Copying files..."
echo "Restart IIS Server..."
iisreset
echo "Installation Complete. System ready to use..."
pause
goto exit

:noparameter
echo Usage: update.bat [DB ServerName] [DBName] [DB UserName] [Password]
pause

:exit
