Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for deloutlx.bat

(view source code of deloutlx.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version and command line arguments
  3. IF "%OS%"=="Windows_NT" (SETLOCAL) ELSE (GOTO Syntax)
  4. IF NOT "%~1"=="" GOTO Syntax
  5. VER | FIND "Windows 2000" >NUL
  6. IF ERRORLEVEL 1 GOTO Syntax
  7.  
  8. :: Check admin access
  9. SET Domain=/DOMAIN
  10. FOR /F "tokens=2*" %%A IN ('NET CONFIG WORKSTATION 2^>NUL ^| FIND /I "Logon domain "') DO IF /I "%%B"=="%ComputerName%" SET Domain=
  11. SET Admin=0
  12. NET USER %UserName% %Domain% 2>NUL | FIND "*" | FIND /I "Admin" >NUL
  13. IF ERRORLEVEL 1 (
  14. 	FOR /F "tokens=*" %%A IN ('NET LOCALGROUP Administrators 2^>NUL ^| FIND /I "%UserName%"') DO FOR %%a IN (%%A) DO IF /I "%%~a"=="%UserName%" SET Admin=1
  15. ) ELSE (
  16. 	SET Admin=1
  17. )
  18. IF NOT [%Admin%]==[1] (
  19. 	CLS
  20. 	ECHO.
  21. 	ECHO This batch file requires administrative permissions on the local computer.
  22. 	ECHO You do not seem to have these permissions.
  23. 	ECHO If continue without the right permissions the procedure will probably fail
  24. 	ECHO halfway through.
  25. 	SET /P Answer=Are you sure you want to try anyway? [y/N] 
  26. )
  27. IF NOT [%Admin%]==[1] IF /I NOT [%Answer%]==[Y] GOTO Syntax
  28.  
  29.  
  30. :Disclaimer
  31. CLS
  32. ECHO.
  33. ECHO You are about to uninstall Outlook Express from your computer.
  34. ECHO.
  35. ECHO This uninstall procedure involves editing the registry and removing
  36. ECHO system files and directories.
  37. ECHO The procedure has been tested only once, on my own computer running
  38. ECHO Windows 2000 Professional (UK) Service Pack 4.
  39. ECHO.
  40. ECHO If you would ask Microsoft about editing the registry or removing
  41. ECHO system files, they would probably advise against it. So do I.
  42. ECHO So if you insist on using this batch file you do so at your own risk.
  43. ECHO.
  44. ECHO By using this script you accept full responsibility for any damage
  45. ECHO it may cause!
  46. ECHO.
  47. ECHO Type YES if you have read and understood this disclaimer and accept
  48. ECHO full responsibility, otherwise press Enter to abort.
  49. ECHO.
  50. SET /P Answer=
  51. IF [%Answer%]==[YES] GOTO Go
  52. ECHO.
  53. ECHO [Aborted on user's request]
  54. GOTO:EOF
  55.  
  56.  
  57. :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
  58. ::                                                                            ::
  59. :: Note:  Throughout this script the variable ERRORDESCR contains a short     ::
  60. ::        description of the possible cause if the following commands fail.   ::
  61. ::                                                                            ::
  62. :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
  63.  
  64.  
  65. :Go
  66. :: Check the exact locations of the files to be removed
  67. SET OutlookExpDir=%ProgramFiles%\Outlook Express
  68. SET ErrorDescr=Directory %OutlookExpDir% not found
  69. IF NOT EXIST "%OutlookExpDir%" GOTO Error
  70. SET System32Dir=%WinDir%\System32
  71. SET ErrorDescr=Directory %System32Dir% not found
  72. IF NOT EXIST "%System32Dir%"   GOTO Error
  73. SET DllCacheDir=%System32Dir%\DllCache
  74. SET ErrorDescr=Directory %DllCacheDir% not found
  75. IF NOT EXIST "%DllCacheDir%"   GOTO Error
  76.  
  77. :: Create a directory to store files and directories to be removed
  78. SET ArchiveDir=%ProgramFiles%\OutlookUninstArchive
  79. IF NOT EXIST "%ArchiveDir%" MD "%ArchiveDir%"
  80. SET ErrorDescr=Directory %ArchiveDir% could not be created
  81. IF NOT EXIST "%ArchiveDir%" GOTO Error
  82.  
  83. :: Create a list of files to be removed
  84. >  "%ArchiveDir%\Outlook_files.txt" ECHO %System32Dir%\inetcomm.dll
  85. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\inetcomm.dll
  86. >> "%ArchiveDir%\Outlook_files.txt" ECHO %System32Dir%\msoeacct.dll
  87. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\msoeacct.dll
  88. >> "%ArchiveDir%\Outlook_files.txt" ECHO %System32Dir%\msoert2.dll
  89. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\msoert2.dll
  90. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\msoe.dll
  91. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\msoe.dll
  92. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\msoeres.dll
  93. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\msoeres.dll
  94. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\msimn.exe
  95. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\msimn.exe
  96. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\oeimport.dll
  97. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\oeimport.dll
  98. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\oemiglib.dll
  99. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\oemiglib.dll
  100. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\oemig50.exe
  101. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\oemig50.exe
  102. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\setup50.exe
  103. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\setup50.exe
  104. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\wab.exe
  105. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\wab.exe
  106. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\wabfind.dll
  107. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\wabfind.dll
  108. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\wabimp.dll
  109. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\wabimp.dll
  110. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\wabmig.exe
  111. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\wabmig.exe
  112. >> "%ArchiveDir%\Outlook_files.txt" ECHO %OutlookExpDir%\csapi3t1.dll
  113. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\csapi3t1.dll
  114. >> "%ArchiveDir%\Outlook_files.txt" ECHO %CommonProgramFiles%\System\directdb.dll
  115. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\directdb.dll
  116. >> "%ArchiveDir%\Outlook_files.txt" ECHO %CommonProgramFiles%\System\wab32.dll
  117. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\wab32.dll
  118. >> "%ArchiveDir%\Outlook_files.txt" ECHO %CommonProgramFiles%\System\wab32res.dll
  119. >> "%ArchiveDir%\Outlook_files.txt" ECHO %DllCacheDir%\wab32res.dll
  120.  
  121. :: Check if all files from the list are there, abort if not
  122. SET AllFilesExist=0
  123. SET ErrorDescr=One or more files were missing
  124. IF EXIST "%ArchiveDir%\Outlook_files.txt" SET AllFilesExist=1
  125. FOR /F "tokens=* delims=" %%A IN ('TYPE "%ArchiveDir%\Outlook_files.txt"') DO IF NOT EXIST "%%~A" (
  126. 	SET AllFilesExist=0
  127. 	ECHO File not found: "%%~A"
  128. )
  129. IF NOT [%AllFilesExist%]==[1] GOTO Error
  130.  
  131. :: Create a list of directories to be removed
  132. >  "%ArchiveDir%\Outlook_dirs.txt" ECHO %CommonProgramFiles%\Microsoft Shared\Stationery
  133. >> "%ArchiveDir%\Outlook_dirs.txt" ECHO %UserProfile%\Application Data\Identities
  134. >> "%ArchiveDir%\Outlook_dirs.txt" ECHO %UserProfile%\Local Settings\Application Data\Identities
  135. >> "%ArchiveDir%\Outlook_dirs.txt" ECHO %UserProfile%\Application Data\Microsoft\Address Book
  136. >> "%ArchiveDir%\Outlook_dirs.txt" ECHO %UserProfile%\Local Settings\Application Data\Address Book
  137.  
  138. :: Check if all directories from the list are there, abort if not
  139. SET AllDirsExist=0
  140. SET ErrorDescr=One or more directories were missing
  141. IF EXIST "%ArchiveDir%\Outlook_dirs.txt" SET AllDirsExist=1
  142. FOR /F "tokens=* delims=" %%A IN ('TYPE "%ArchiveDir%\Outlook_dirs.txt"') DO IF NOT EXIST "%%~A\." (
  143. 	ECHO.%%~A | FIND /I "%UserProfile%" >NUL
  144. 	IF ERRORLEVEL 1 SET AllDirsExist=0
  145. 	ECHO Directory not found: "%%~A"
  146. )
  147. IF NOT [%AllDirsExist%]==[1] GOTO Error
  148.  
  149. :: Create a directory to store export files of registry keys to be removed
  150. IF NOT EXIST "%ArchiveDir%\Registry" MD "%ArchiveDir%\Registry"
  151. SET ErrorDescr=Directory %ArchiveDir%\Registry could not be created
  152. IF NOT EXIST "%ArchiveDir%\Registry" GOTO Error
  153.  
  154. :: Create a list of registry entries to be removed
  155. >  "%ArchiveDir%\Outlook.del" ECHO REGEDIT4
  156. >> "%ArchiveDir%\Outlook.del" ECHO.
  157. >> "%ArchiveDir%\Outlook.del" ECHO [-HKEY_LOCAL_MACHINE\Software\Microsoft\Outlook Express]
  158. >> "%ArchiveDir%\Outlook.del" ECHO.
  159. >> "%ArchiveDir%\Outlook.del" ECHO [-HKEY_LOCAL_MACHINE\Software\Microsoft\WAB]
  160. >> "%ArchiveDir%\Outlook.del" ECHO.
  161. >> "%ArchiveDir%\Outlook.del" ECHO [-HKEY_CURRENT_USER\Identities]
  162. >> "%ArchiveDir%\Outlook.del" ECHO.
  163. >> "%ArchiveDir%\Outlook.del" ECHO [-HKEY_CURRENT_USER\Software\Microsoft\Outlook Express]
  164. >> "%ArchiveDir%\Outlook.del" ECHO.
  165. >> "%ArchiveDir%\Outlook.del" ECHO [-HKEY_CURRENT_USER\Software\Microsoft\WAB]
  166. >> "%ArchiveDir%\Outlook.del" ECHO.
  167. >> "%ArchiveDir%\Outlook.del" ECHO [-HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}]
  168. >> "%ArchiveDir%\Outlook.del" ECHO.
  169. >> "%ArchiveDir%\Outlook.del" ECHO [-HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{7790769C-0471-11D2-AF11-00C04FA35D02}]
  170. >> "%ArchiveDir%\Outlook.del" ECHO.
  171.  
  172. :: Export the registry entries to be removed, abort on failure
  173. SET AllRegExist=0
  174. SET ErrorDescr=
  175. IF EXIST "%ArchiveDir%\Outlook.del" SET AllRegExist=1
  176. CALL :ExportReg "HKLM_OutlookExpress.reg" "HKEY_LOCAL_MACHINE\Software\Microsoft\Outlook Express"
  177. CALL :ExportReg "HKLM_WAB.reg"            "HKEY_LOCAL_MACHINE\Software\Microsoft\WAB"
  178. CALL :ExportReg "HKCU_Identities.reg"     "HKEY_CURRENT_USER\Identities"
  179. CALL :ExportReg "HKCU_OutlookExpress.reg" "HKEY_CURRENT_USER\Software\Microsoft\Outlook Express"
  180. CALL :ExportReg "HKCU_WAB.reg"            "HKEY_CURRENT_USER\Software\Microsoft\WAB"
  181. CALL :ExportReg "HKLM_00AA00B6015C.reg"   "HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}"
  182. CALL :ExportReg "HKLM_00C04FA35D02.reg"   "HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\{7790769C-0471-11D2-AF11-00C04FA35D02}"
  183. IF NOT [%AllRegExist%]==[1] GOTO Error
  184.  
  185. :: Create the directories where the files and directories
  186. :: to be removed will be stored, or abort on failure
  187. SET AllDirsCreated=1
  188. SET ErrorDescr=One or more directories could not be created
  189. FOR /F "tokens=* delims=" %%A IN ('TYPE "%ArchiveDir%\Outlook_files.txt"') DO (
  190. 	IF NOT EXIST "%ArchiveDir%%%~pA" MD "%ArchiveDir%%%~pA"
  191. 	IF NOT EXIST "%ArchiveDir%%%~pA" (
  192. 		ECHO Error creating directory "%ArchiveDir%%%~pA"
  193. 		SET AllDirsCreated=0
  194. 	)
  195. )
  196. FOR /F "tokens=* delims=" %%A IN ('TYPE "%ArchiveDir%\Outlook_dirs.txt"') DO (
  197. 	IF NOT EXIST "%ArchiveDir%%%~pA" MD "%ArchiveDir%%%~pA"
  198. 	IF NOT EXIST "%ArchiveDir%%%~pA" (
  199. 		ECHO Error creating directory "%ArchiveDir%%%~pA"
  200. 		SET AllDirsCreated=0
  201. 	)
  202. )
  203. IF NOT [%AllDirsCreated%]==[1] GOTO Error
  204.  
  205. :: Move the files and directories and remove the registry entries
  206. FOR /F "tokens=* delims=" %%A IN ('TYPE "%ArchiveDir%\Outlook_dirs.txt"')  DO IF EXIST "%%~A" MOVE /Y "%%~A" "%ArchiveDir%%%~pA"
  207. START /WAIT REGEDIT.EXE /S "%ArchiveDir%\Outlook.del"
  208. FOR /F "tokens=* delims=" %%A IN ('TYPE "%ArchiveDir%\Outlook_files.txt"') DO IF EXIST "%%~A" MOVE /Y "%%~A" "%ArchiveDir%%%~pA"
  209.  
  210. :: Done
  211. ENDLOCAL
  212. GOTO:EOF
  213.  
  214.  
  215. :ExportReg
  216. SET RegFile=%~1
  217. SET RegKey=%~2
  218. IF NOT DEFINED RegKey (
  219. 	SET AllRegExist=0
  220. 	GOTO:EOF
  221. )
  222. SET ErrorDescr=One or more registry keys could not be exported
  223. START /WAIT REGEDIT.EXE /E "%ArchiveDir%\Registry\%RegFile%" "%RegKey%"
  224. TYPE "%ArchiveDir%\Registry\%RegFile%" 2>NUL | FIND /I "[%RegKey%]" >NUL
  225. IF ERRORLEVEL 1 (
  226. 	SET AllRegExist=0
  227. 	ECHO Error exporting registry key [%RegKey%]
  228. )
  229. GOTO:EOF
  230.  
  231.  
  232. :Error
  233. ECHO.
  234. ECHO The batch file encountered at least one error:
  235. ECHO.%ErrorDescr%
  236. ECHO No files, directories or registry keys were moved or deleted yet.
  237. ECHO The process is aborted.
  238.  
  239.  
  240. :Syntax
  241. ECHO.
  242. ECHO DelOutlX.bat,  Version 0.41 Beta for Windows 2000
  243. ECHO Uninstall Outlook Express from the local computer
  244. ECHO.
  245. ECHO Usage:    DELOUTLX  [ /? ]
  246. ECHO.
  247. ECHO Notes:    This batch file requires Administrator rights on the local system.
  248. IF DEFINED ArchiveDir (
  249. 	ECHO           The files to be removed are actually stored in the directory
  250. 	ECHO           "%ArchiveDir%"
  251. )
  252. ECHO.
  253. ECHO Warning:  This batch file removes system files and registry entries.
  254. ECHO           This is NOT without risk, to say the least.
  255. ECHO           Make sure you understand the implications before running this script,
  256. ECHO           and that you have a full backup of your system, plus the required
  257. ECHO           software to restore it.
  258. ECHO           USE THIS BATCH FILE ENTIRELY AT YOUR OWN RISK!
  259. ECHO.
  260. ECHO Written by Rob van der Woude
  261. ECHO http://www.robvanderwoude.com
  262.  
  263. IF "%OS%"=="Windows_NT" ENDLOCAL
  264.  

page last modified: 2024-04-16; loaded in 0.0123 seconds