@echo off
echo CLEARCONTEXT CLEARCONTEXT COMPLETE REMOVAL
echo This seven-step process will completely remove ClearContext
echo in the event that the installer has
echo become corrupted.
echo Please ensure that Outlook is closed.
pause

echo ---
echo (1/7) AUTOASSIGN BACKUP
echo This will backup your ClearContext rules
echo in the file C:\temp\cc-autoassign.reg
pause
md c:\temp
reg export hkcu\software\ClearContext\ClearMail\AnalyzeJobs c:\temp\cc-autoassign.reg
echo Run cc-autoassign.reg on another machine to transfer your AutoAssign settings.
pause

echo ---
echo (2/7) USER DATABASE BACKUP (STATS, TOPIC SUGGESTIONS)
echo This will backup your ClearContext User Database
echo in the file C:\temp\cc_user.db
pause
copy "%USERPROFILE%\AppData\Local\ClearContext\ClearContext Information Management System\cc_user.db" C:\temp\cc_user.db
copy "%USERPROFILE%\Local Settings\Application Data\ClearContext\ClearContext Information Management System\cc_user.db" C:\temp\cc_user.db
echo If you see "1 file(s) copied" at least once above,
echo the operation was successful
echo After reinstall, copy C:\temp\cc_user.db to your ClearContext local settings
echo directory (directions below)
pause

echo ---
echo (3/7) UNINSTALL CLEARCONTEXT via WINDOWS
echo Attempt to uninstall ClearContext via Control Panel -
echo Add-Remove Programs (XP) or Programs (Vista)
echo Please remove before continuing.
pause

echo ---
echo (4/7) UNREGISTER CLEARCONTEXT
echo This step will attempt to manually unregister ClearContext
echo You may receive an error that it already uninstalled
echo or that another version is already installed.
echo If so, please note the error and continue with the process
pause
msiexec /x clearcontext.msi
echo Unregistration complete.

echo ---
echo (5/7) REMOVE REGISTRY ENTRIES
echo This will clear all known ClearContext registry entries
echo You may be asked to grant permission for regedit
echo to make its changes.
pause
remove_ims.reg
pause

echo ---
echo (6/7) DELETE CLEARCONTEXT INSTALL DIRECTORIES
echo We will now attempt to delete ClearContext install directories
pause
rd "%PROGRAMFILES%\ClearContext" /s
rd "%USERPROFILE%\AppData\Local\ClearContext" /s
rd "%USERPROFILE%\Local Settings\Application Data\ClearContext" /s
echo Removal complete.  
pause

echo ---
echo (7/7) MANUALLY FORCE REMOVAL OF CLEARCONTEXT FROM WINDOWS
echo Run the Windows Installer Cleanup Utility (msicuu2.exe)
echo in the directory that you extracted this file to.
echo -
echo You may need to install this application as an Administrator.
echo If so, download to your hard drive and right click the file to select
echo "Run as Administrator"
echo -
echo Once installation is complete, launch the program.
echo via Start > Programs.
echo If ClearContext is listed please follow
echo directions to remove ClearContext via this utility.
echo -
echo Once this process is complete, return to this screen.
pause

echo ---
echo REMOVAL PROCESS COMPLETE
echo Once you are done with the Windows Installer CleanUp Utility,
echo this removal process is complete.  If you are working with
echo ClearContext Support, please copy the contents of this window
echo by clicking the icon in the upper left hand corner
echo selecting Edit > Select All
echo the selecting Edit > Copy
echo Paste this into a Word document or some other place
echo so that you can send to support should you need to.
echo ---
echo PRODUCT REINSTALLATION
echo If you would like to reinstall the application,
echo follow these directions:
echo 1. Reboot Windows.
echo 2. Log in under the user rights that you intend to run Outlook under.
echo 3. Do NOT open Outlook.
echo 4. Download and install ClearContext from the ClearContext website.
echo    Do NOT select install as Administrator; run under your normal user name.
echo 3. Once complete, open Outlook.
echo 4. If the application does not start, follow directions here to re-enable:
echo    http://www.clearcontext.com/faq.html#reenable
echo    Please note that there are two places to attempt to re-enable.
echo 5. Once installation is complete, run C:\temp\cc-autoassign.reg to restore
echo    your AutoAssign rules.
echo 6. After you run through setup in Outlook, copy c:\temp\cc_user.db into your
echo	ClearContext Local Settings Directory:
echo	WINXP: "%USERPROFILE%\Local Settings\Application Data\ClearContext\ClearContext Information Management System\"
echo	VISTA: "%USERPROFILE%\AppData\Local\ClearContext\ClearContext Information Management System\"
echo ---
echo This utility is now complete.
pause

exit