echo.>> Begin
pushd %~dp0
set FILE=%~pf0
if not exist "%FILE%" goto :eof
set BAT_DIR=%~dp0
set REG_DIR=%BAT_DIR:\=\\%
echo.>> Begin1
REM setup common registry entries
echo Windows Registry Editor Version 5.00                         >  "%BAT_DIR%"\common.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_myhome]                  >> "%BAT_DIR%"\common.reg
echo "ORACLE_HOME"="%REG_DIR%"                                    >> "%BAT_DIR%"\common.reg
echo "ORACLE_HOME_NAME"="myhome"                                      >> "%BAT_DIR%"\common.reg
echo "ORACLE_GROUP_NAME"="Oracle - myhome"                            >> "%BAT_DIR%"\common.reg
echo "NLS_LANG"="AMERICAN_AMERICA.WE8MSWIN1252"                   >> "%BAT_DIR%"\common.reg

regedit /s "%BAT_DIR%\common.reg"
del /q "%BAT_DIR%\common.reg"

REM not all components create bin dir and copy files over
if EXIST "%BAT_DIR%"\bin\*.* (
 echo SOFTWARE\ORACLE\KEY_myhome> "%BAT_DIR%bin\oracle.key"
)
echo SOFTWARE\ORACLE\KEY_myhome> "%BAT_DIR%oracle.key"


popd

echo.>> install.log
echo ************************************* >> install.log
echo Basic Oracle Instant Client installed >> install.log
echo ************************************* >> install.log
echo.>> install.log


echo ****************************************** >> install.log
echo Installing Oracle Data Provider for .NET 4 >> install.log
echo ****************************************** >> install.log

REM copy the files


REM not calling confifure.bat as follows since on Win2k when dir names contain 
REM a space it has issues when retreiving CURRENT DIR in configure.bat
REM call %1\configure.bat odp.net4 %3


REM echo Please wait... configuring Oracle Data Provider for .NET 4

echo ******************************************* >> install.log
echo Configuring Oracle Data Provider for .NET 4 >> install.log
echo ******************************************* >> install.log

REM Check if .NET Framework exists
if EXIST "%SystemRoot%"\Microsoft.NET\Framework\v4.0.30319\*.* (

REM Enter the odp 4 assembly in the GAC
"%BAT_DIR%"odp.net\bin\4\OraProvCfg.exe /action:gac /providerpath:"%BAT_DIR%odp.net\bin\4\Oracle.DataAccess.dll" >> install.log

REM Enter the odp 4 publisher policy in the GAC
"%BAT_DIR%"odp.net\bin\4\OraProvCfg.exe /action:gac /providerpath:"%BAT_DIR%odp.net\PublisherPolicy\4\Policy.4.112.Oracle.DataAccess.dll" >> install.log

REM configure machine.config for Framework 4 with proper section handler
"%BAT_DIR%"odp.net\bin\4\OraProvCfg.exe /action:config /product:odp /frameworkversion:v4.0.30319 /providerpath:"%BAT_DIR%odp.net\bin\4\Oracle.DataAccess.dll" >> install.log

REM register the counters
"%BAT_DIR%"odp.net\bin\4\OraProvCfg.exe /action:register /product:odp /component:perfcounter /providerpath:"%BAT_DIR%odp.net\bin\4\Oracle.DataAccess.dll" >> install.log


REM **********************************************************
REM OPTIONAL SETUP - LANGUAGE SPECIFIC ODP.NET 4 RESOURCE DLLS
REM **********************************************************

REM Enter the ODP.NET 4 resource assemblies in the GAC
"%BAT_DIR%"odp.net\bin\4\OraProvCfg.exe /action:gac /providerpath:"%BAT_DIR%odp.net\bin\4\Resources\zh-CHS\Oracle.DataAccess.resources.dll" >> install.log
"%BAT_DIR%"odp.net\bin\4\OraProvCfg.exe /action:gac /providerpath:"%BAT_DIR%odp.net\bin\4\Resources\zh-CHT\Oracle.DataAccess.resources.dll" >> install.log
)

REM setup registry entries for ODP.NET 4
echo Windows Registry Editor Version 5.00                                     >  "%BAT_DIR%"\odp.net.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET]                             >> "%BAT_DIR%"\odp.net.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.112.4.0]                   >> "%BAT_DIR%"\odp.net.reg
echo "DllPath"="%REG_DIR%bin"                                                 >> "%BAT_DIR%"\odp.net.reg
echo "PromotableTransaction"="promotable"                                     >> "%BAT_DIR%"\odp.net.reg
echo "StatementCacheWithUdts"="1"                                             >> "%BAT_DIR%"\odp.net.reg
echo "TraceFileName"="c:\\odpnet4.trc"                                        >> "%BAT_DIR%"\odp.net.reg
echo "TraceLevel"="0"                                                         >> "%BAT_DIR%"\odp.net.reg
echo "TraceOption"="0"                                                        >> "%BAT_DIR%"\odp.net.reg
echo "PerformanceCounters"="0"                                                >> "%BAT_DIR%"\odp.net.reg
echo "UdtCacheSize"="4096"                                                    >> "%BAT_DIR%"\odp.net.reg
echo "DemandOraclePermission"="0"                                             >> "%BAT_DIR%"\odp.net.reg
echo "SelfTuning"="0"                                                         >> "%BAT_DIR%"\odp.net.reg
echo "MaxStatementCacheSize"="100"                                            >> "%BAT_DIR%"\odp.net.reg

regedit /s "%BAT_DIR%\odp.net.reg"
del /q "%BAT_DIR%\odp.net.reg"

echo Create a registry entry to add managed assembly in the Add Reference Dialog box in VS.NET >> install.log
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\ODP.Net" /ve /t REG_SZ /d "%BAT_DIR%odp.net\bin\4" /f >> install.log

echo.>> install.log
echo ****************************************** >> install.log
echo Oracle Data Provider for .NET 4 configured >> install.log
echo ****************************************** >> install.log
echo.>> install.log
REM echo Oracle Data Provider for .NET configured in an Oracle Instant Client Home.
REM echo Please wait... configuring Oracle Services for MTS

echo *********************************** >> install.log
echo Configuring Oracle Services for MTS >> install.log
echo *********************************** >> install.log

REM Add <Oracle Home> to the PATH environment variable
set PATH=%BAT_DIR%;%BAT_DIR%bin;%PATH%

REM configure.bat will be run from the destination orcl_home dir
REM after oramts files have been copied over in the destination orcl_home dir
set src_dir=%BAT_DIR%
set dst_dir=%BAT_DIR%

set reco_username=%userdomain%\%username%
REM set some local env vars used by genreg, etc.
set orcl_home=%dst_dir%
set reco_port=2030
set reco_host=%computername%
set reco_password=
set reco_username=LocalSystem
set oramts_ver=11.2.0.4.0
set svc_binary="%orcl_home%bin\omtsreco.exe \"OracleMTSRecoveryService\""
set inst_dir=%src_dir%oramts\install
set reg_file=setup_reg.reg

REM echo creating OracleMTSRecoveryService ....
sc.exe stop   OracleMTSRecoveryService > NUL 2>&1
sc.exe delete OracleMTSRecoveryService > NUL 2>&1
sc.exe create OracleMTSRecoveryService binpath= %svc_binary%  start= auto >> install.log
REM OracleMTSRecoveryService was successfully created with the LocalSystem
REM account as the logon account. Make sure to change the logon  credentials 
REM of this service using the "services" administration tool. Please read the
REM README.TXT under %orcl_home%\oramts\doc.

REM creating registry entries for OraMTS ....
pushd %inst_dir%
call genreg.bat install myhome > %reg_file%
regedit -s %reg_file%
REM echo created registry entries for OraMTS successfully

REM echo starting OracleMTSRecoveryService ...
REM net start  OracleMTSRecoveryService
REM echo started OracleMTSRecoveryService successfully

del %reg_file%
popd
echo.>> install.log
echo ********************************** >> install.log
echo Oracle Services for MTS configured >> install.log
echo ********************************** >> install.log
echo.>> install.log
echo.
REM echo Oracle Services for MTS configured in an Oracle Instant Client Home.


goto :EOF
echo.>> wrong "%FILE%"

