
pushd %~dp0

set FILE=%~pf0
if not exist "%FILE%" goto :eof
echo %FILE%

set BATCH_DIR=%cd%\

set ohname=myhome

if EXIST myhome\oracle.key goto :get_oraclehomename
goto :continue

:get_oraclehomename
for /f "delims=_ tokens=1,*" %%i in ('type %ohname%\oracle.key') do set ohname=%%j

:continue
echo ohname

REM proceed only if component is installed 
if EXIST oci.dll ( 
 
echo **************************************** >> uninstall.log 
echo Uninstalling Basic Oracle Instant Client >> uninstall.log 
echo **************************************** >> uninstall.log 
 
del /f adrci.exe  2>nul
del /f adrci.sym  2>nul
del /f BASIC_README  2>nul
del /f genezi.exe  2>nul
del /f genezi.sym  2>nul
del /f oci.dll  2>nul
del /f oci.sym  2>nul
del /f ocijdbc11.dll  2>nul
del /f ocijdbc11.sym  2>nul
del /f ociw32.dll  2>nul
del /f ociw32.sym  2>nul
del /f ojdbc5.jar  2>nul
del /f ojdbc6.jar  2>nul
del /f orannzsbb11.dll  2>nul
del /f orannzsbb11.sym  2>nul
del /f oraocci11.dll  2>nul
del /f oraocci11.sym  2>nul
del /f oraociei11.dll  2>nul
del /f oraociei11.sym  2>nul
del /f orasql11.dll  2>nul
del /f orasql11.sym  2>nul
del /f uidrvci.exe  2>nul
del /f uidrvci.sym  2>nul
del /f xstreams.jar  2>nul
del /f vc8\oraocci11.dll  2>nul
del /f vc8\oraocci11.sym  2>nul
del /f vc9\oraocci11.dll  2>nul
del /f vc9\oraocci11.sym  2>nul
rmdir vc9 2>nul 
rmdir vc8 2>nul 
 
echo.>> uninstall.log 
echo *************************************** >> uninstall.log 
echo Basic Oracle Instant Client uninstalled >> uninstall.log 
echo *************************************** >> uninstall.log 
echo.>> uninstall.log 
) 

REM proceed only if component is installed 
if EXIST odp.net\bin\4\Oracle.DataAccess.dll ( 
 
echo ******************************************** >> uninstall.log 
echo Uninstalling Oracle Data Provider for .NET 4 >> uninstall.log 
echo ******************************************** >> uninstall.log 
 

echo ********************************************* >> uninstall.log
echo Unconfiguring Oracle Data Provider for .NET 4 >> uninstall.log
echo ********************************************* >> uninstall.log


REM Check if .NET Framework exists
if EXIST "%SystemRoot%"\Microsoft.NET\Framework\v4.0.30319\*.* (

REM ***************************************************************
REM REMOVE ALL LANGUAGE SPECIFIC ODP.NET RESOURCE DLLS FROM THE GAC
REM ***************************************************************
"%BATCH_DIR%"odp.net\bin\4\OraProvCfg.exe /action:ungac /providerpath:"Oracle.DataAccess.resources, Version=4.112.4.0,processorArchitecture=AMD64" >> uninstall.log

REM Unregister the counters
"%BATCH_DIR%"odp.net\bin\4\OraProvCfg.exe /action:unregister /product:odp /component:perfcounter /providerpath:"%BATCH_DIR%odp.net\bin\4\Oracle.DataAccess.dll" >> uninstall.log

REM remove odp section handler from machine.config for Framework 4
"%BATCH_DIR%"\odp.net\bin\4\OraProvCfg.exe /action:unconfig /product:odp /frameworkversion:v4.0.30319 >> uninstall.log

REM remove the odp 4 publisher policy in the GAC
"%BATCH_DIR%"\odp.net\bin\4\OraProvCfg.exe /action:ungac /providerpath:"Policy.4.112.Oracle.DataAccess, Version=4.112.4.0,processorArchitecture=AMD64" >> uninstall.log

REM remove the odp 4 assembly in the GAC
"%BATCH_DIR%"\odp.net\bin\4\OraProvCfg.exe /action:ungac /providerpath:"Oracle.DataAccess, Version=4.112.4.0,processorArchitecture=AMD64" >> uninstall.log

)

REM remove registry entries for ODP.NET 4
echo Windows Registry Editor Version 5.00                     >  "%BATCH_DIR%"\odp.net.reg
echo [-HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.112.4.0]  >> "%BATCH_DIR%"\odp.net.reg
	
regedit /s "%BATCH_DIR%\odp.net.reg"
del /q "%BATCH_DIR%\odp.net.reg"

echo Delete the registry entry to remove managed assembly in the Add Reference Dialog box in VS.NET >> uninstall.log
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\ODP.Net" /f >> uninstall.log

echo.>> uninstall.log
echo ******************************************** >> uninstall.log
echo Oracle Data Provider for .NET 4 unconfigured >> uninstall.log
echo ******************************************** >> uninstall.log
echo.>> uninstall.log

REM echo ODP.NET 4 is now unconfigured.
 
del /f odp.net\bin\4\Oracle.DataAccess.dll  2>nul
del /f odp.net\bin\4\OraProvCfg.exe  2>nul
del /f odp.net\bin\4\Resources\zh-CHS\Oracle.DataAccess.resources.dll  2>nul
del /f odp.net\bin\4\Resources\zh-CHT\Oracle.DataAccess.resources.dll  2>nul
del /f odp.net\PublisherPolicy\4\Policy.4.112.Oracle.DataAccess.config  2>nul
del /f odp.net\PublisherPolicy\4\Policy.4.112.Oracle.DataAccess.dll  2>nul
REM oraops11w.dll and readme.htm are common to both odp.net 2.x and odp.net 4 
REM Remove only if odp.net is not present 
if NOT EXIST odp.net\bin\2.x\Oracle.DataAccess.dll ( 
del /f bin\OraOps11w.dll  2>nul
del /f odp.net\doc\readme.htm  2>nul
) 
rmdir odp.net\PublisherPolicy\4 2>nul 
rmdir odp.net\bin\4\Resources\zh-CHT 2>nul 
rmdir odp.net\bin\4\Resources\zh-CHS 2>nul 
rmdir odp.net\bin\4 2>nul 
rmdir odp.net\PublisherPolicy 2>nul 
rmdir odp.net\doc 2>nul 
rmdir odp.net\bin 2>nul 
rmdir odp.net 2>nul 
rmdir bin 2>nul 
 
echo.>> uninstall.log 
echo ******************************************* >> uninstall.log 
echo Oracle Data Provider for .NET 4 uninstalled >> uninstall.log 
echo ******************************************* >> uninstall.log 
echo.>> uninstall.log 
) 
 
REM echo ODP.NET 4 now uninstalled in an Oracle Instant Client Home. 
REM proceed only if component is installed 
if EXIST bin\oramts11.dll ( 
 
echo ************************************ >> uninstall.log 
echo Uninstalling Oracle Services for MTS >> uninstall.log 
echo ************************************ >> uninstall.log 

rem set some local env vars used by genreg, etc.
set reg_file=clean_registry.reg

echo Deleting OracleMTSRecoveryService .... >> uninstall.log
sc.exe stop   OracleMTSRecoveryService > NUL 2>&1
sc.exe delete OracleMTSRecoveryService >> uninstall.log

echo Cleaning up registry entries for OraMTS .... >> uninstall.log

pushd %BATCH_DIR%
call oramts\install\genreg.bat deinstall %ohname% > %reg_file%
regedit -s %reg_file%
del %reg_file%
popd
 
del /f bin\omtsreco.exe  2>nul
del /f bin\omtsrecoevntd.dll  2>nul
del /f bin\omtsrecoevnte.dll  2>nul
del /f bin\omtsrecoevntf.dll  2>nul
del /f bin\omtsrecoevnti.dll  2>nul
del /f bin\omtsrecoevntja.dll  2>nul
del /f bin\omtsrecoevntko.dll  2>nul
del /f bin\omtsrecoevntptb.dll  2>nul
del /f bin\omtsrecoevntus.dll  2>nul
del /f bin\omtsrecoevntzhs.dll  2>nul
del /f bin\omtsrecoevntzht.dll  2>nul
del /f bin\omtsrecomsgus.dll  2>nul
del /f bin\oramts.dll  2>nul
del /f bin\oramts11.dll  2>nul
del /f bin\oramtsus.dll  2>nul
del /f oramts\admin\oramtsadmin.sql  2>nul
del /f oramts\admin\prvtoramts.plb  2>nul
del /f oramts\admin\utl_oramts.sql  2>nul
del /f oramts\doc\readme.txt  2>nul
del /f oramts\install\genreg.bat  2>nul
rmdir oramts\trace 2>nul 
rmdir oramts\install 2>nul 
rmdir oramts\doc 2>nul 
rmdir oramts\admin 2>nul 
rmdir oramts 2>nul 
rmdir bin 2>nul 
 
echo.>> uninstall.log 
echo *********************************** >> uninstall.log 
echo Oracle Services for MTS uninstalled >> uninstall.log 
echo *********************************** >> uninstall.log 
echo.>> uninstall.log 
) 
 
REM echo ORAMTS now uninstalled from an Oracle Instant Client Home. 
 

echo Registry entries for OraMTS cleaned up successfully >> uninstall.log
echo.>> uninstall.log
echo ************************************ >> uninstall.log
echo Oracle Services for MTS unconfigured >> uninstall.log
echo ************************************ >> uninstall.log
echo.>> uninstall.log

REM echo ORAMTS is now unconfigured.

popd
goto :EOF 

