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

echo ---
echo (1/6) 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/6) UNINSTALL IMS via WINDOWS
echo Attempt to uninstall IMS via Control Panel -
echo Add-Remove Programs (XP) or Programs (Vista)
echo Please remove before continuing.
pause

echo ---
echo (3/6) UNREGISTER IMS
echo This step will attempt to manually unregister IMS
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 (4/6) REMOVE REGISTRY ENTRIES
echo This will clear all known IMS registry entries
echo You may be asked to grant permission for regedit
echo to make its changes.
pause
remove_ims.reg
pause

echo ---
echo (5/6) DELETE IMS INSTALL DIRECTORIES
echo We will now attempt to delete IMS 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 (6/6) MANUALLY FORCE REMOVAL OF IMS 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 IMS 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 IMS 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 ---
echo This utility is now complete.
pause

exit