@echo off setlocal enabledelayedexpansion rem ------------------------------------------------------------------- rem DeleteOfflineDBs.bat rem Author: Ben Staveley-Taylor rem rem Copyright (c) 2008, 2009, Oracle and/or its affiliates. rem All rights reserved. rem rem Wipe all Broadside Offline Databases: user, machine and registry rem rem Optional arguments: rem -machinekey deletes Machine key registry rem -user deletes only the current user's offline DB rem -shared deletes only the shared offline DB (the one that Search uses) rem -all deletes everything rem Without -all, only the disk databases are erased. rem rem ------------------------------------------------------------------- pskill irmbackground.exe @ping -n 2 127.0.0.1 > nul pushd %~dp0 rem Parse arguments rem if no arguments, offer usage help. Though no arguments is OK. if "%1" EQU "" ( echo [Optional arguments: -user, -shared, -machinekey, -all echo Defaulting to -user -shared] ) rem Defaults: No arguments means leave the machine key untouched; rem delete both user and shared OLDBs. set DELETEMACHINEKEY=n set DELETEUSEROLDB=y set DELETESHAREDOLDB=y set DELETEALL=n for %%a in (%*) do ( if /i "%%~a" EQU "-machinekey" set DELETEMACHINEKEY=y if /i "%%~a" EQU "-user" set DELETEUSEROLDB=y&set DELETESHAREDOLDB=n if /i "%%~a" EQU "-shared" set DELETEUSEROLDB=n&set DELETESHAREDOLDB=y if /i "%%~a" EQU "-all" set DELETEALL=y ) rem -all overrides everything if %DELETEALL% EQU y ( set DELETEMACHINEKEY=y set DELETEUSEROLDB=y set DELETESHAREDOLDB=y echo Going to delete ALL offline IRM data ) rem compile list of doomed directories rem Documents and Settings folder set DOCSANDSETTINGS=%userprofile%\.. rem Vista Paths are different IF EXIST "%userprofile%\AppData" ( set MACHINEPATH=%allusersprofile% ) ELSE ( set MACHINEPATH=%allusersprofile%\Application Data ) set DIRSTOKILL= if "%DELETEUSEROLDB%" EQU "y" ( rem Remove all users OLDBs for /d %%d in ("%DOCSANDSETTINGS%\*") do ( rem Vista Paths are different IF EXIST "%%d\AppData" ( set USERPATH=%%d\AppData\LocalLow ) ELSE ( set USERPATH=%%d\Local Settings\Application Data ) set DIRSTOKILL=!DIRSTOKILL! "!USERPATH!\Oracle\IRM\OfflineStore" set DIRSTOKILL=!DIRSTOKILL! "!USERPATH!\Oracle\IRM\SecurityStore" ) ) if "%DELETESHAREDOLDB%" EQU "y" ( set DIRSTOKILL=!DIRSTOKILL! "%MACHINEPATH%\Oracle\IRM\OfflineStore" set DIRSTOKILL=!DIRSTOKILL! "%MACHINEPATH%\Oracle\IRM\SecurityStore" ) for %%d in (%DIRSTOKILL%) do ( if exist %%d ( echo Deleting %%d rmdir /s /q %%d if exist %%d echo Failed to remove directory %%d&goto ErrorExit ) ) if "%DELETEMACHINEKEY%" NEQ "y" ( echo. echo *** NOTE: The machine key databases have not been deleted. echo Use '-all' option to delete them too. echo. goto SuccessExit ) echo Deleting machine keys rem Create the reg file to do this set REGFILENAME=%~n0.reg echo Windows Registry Editor Version 5.00>%REGFILENAME% echo.>>%REGFILENAME% echo [-HKEY_LOCAL_MACHINE\Software\Oracle\IRM\StoreSecurity]>>%REGFILENAME% echo [-HKEY_CURRENT_USER\Software\Oracle\IRM\StoreSecurity]>>%REGFILENAME% echo regedit.exe /s %REGFILENAME% regedit.exe /s %REGFILENAME% if errorlevel 1 echo Failed to remove Device keys in registry&goto ErrorExit :SuccessExit echo Success popd @ping -n 4 127.0.0.1 > nul exit /b 0 :ErrorExit echo *** %~n0 FAILED popd pause exit /b 1