SSPCPP-510 - paranoia about failing in the uninstall script
authorRod Widdowson <rdw@steadingsoftware.com>
Fri, 2 Nov 2012 10:11:10 +0000 (10:11 +0000)
committerRod Widdowson <rdw@steadingsoftware.com>
Fri, 2 Nov 2012 10:11:10 +0000 (10:11 +0000)
https://issues.shibboleth.net/jira/browse/SSPCPP-510

msi/scripts/shib_uninstall_isapi_filter.vbs-wix

index 77810bb..979d463 100644 (file)
@@ -2,8 +2,17 @@ Sub DeleteISAPIFilters(IISPath,dllPath)
 \r
   Dim filter, FiltersObj, LoadOrder, FilterArray, FilterItem\r
 \r
+  On Error Resume Next\r
   Set FiltersObj = GetObject(IISPath & "/Filters")\r
+  if IsNull(FiltersObj) then\r
+    exit sub\r
+  end if\r
+\r
+  On Error Resume Next\r
   LoadOrder = FiltersObj.FilterLoadOrder\r
+  if IsNull(LoadOrder) then\r
+    exit sub\r
+  end if\r
 \r
   for each filter in FiltersObj\r
     if (filter.Class = "IIsFilter") then\r
@@ -48,7 +57,11 @@ Dim line, lineArray, lineIndex
 Dim fileExtension\r
 Dim existsFlag\r
 \r
+  On Error Resume Next\r
   ScriptMaps = siteObj.ScriptMaps\r
+  if IsNull(ScriptMaps) then\r
+    exit sub\r
+  end if\r
   redim newScriptMaps(0)\r
   lineIndex = 0\r
   'copy each entry from the old ScriptMaps to newScriptMaps\r
@@ -71,38 +84,38 @@ Dim existsFlag
 \r
 End Sub\r
 \r
+Sub PerformUninstall()\r
 \r
 '*** Begin Main Code ***\r
 Dim WebObj\r
 Dim InstallDir\r
-Dim FileSystemObj\r
 Dim ShibISAPIPath\r
-Dim site, siteObj, sitePath, LogFile\r
+Dim site, siteObj, sitePath\r
+\r
+On Error Resume Next\r
 \r
 ' First of all look for the FileExtension\r
 Set WshShell = CreateObject("WScript.Shell")\r
+if (Err <> 0) then\r
+  exit sub\r
+End if\r
+\r
 \r
 'Get the INSTALLDIR value via CustomActionData\r
+On Error Resume Next\r
 InstallDir = Session.Property("CustomActionData")\r
-\r
-Set FileSystemObj = CreateObject("Scripting.FileSystemObject")\r
-\r
-'Set LogFile = FileSystemObj.OpenTextFile(InstallDir & "\var\log\shibboleth\Installer.log", 8, true)\r
+if (Err <> 0) then\r
+  exit sub\r
+End if\r
 \r
 On Error Resume Next\r
 regValue = WshShell.RegRead("HKLM\SOFTWARE\Shibboleth\FileExtension")\r
 if (Err = 0) then\r
 \r
- ' If (LogFile) then\r
-  '   LogFile.WriteLine "Uninstall IIS plugin - upgrade detected by uninstall script, skipping"\r
-  'End If\r
   ' Registry key is still there - this is an upgrade, so exit\r
 \r
 else \r
   ' Key is gone - a pure uninstall\r
-  'If (LogFile) then\r
-   '  LogFile.WriteLine "Uninstall IIS plugin"\r
-  'End If\r
  \r
   'Don't show errors, we'll handle anything important\r
   On Error Resume Next\r
@@ -144,4 +157,8 @@ else
   ' Got the IIS Object\r
   End If\r
 ' Sense whether this is an upgrade\r
-end if
\ No newline at end of file
+end if\r
+\r
+End Sub\r
+\r
+PerformUninstall()
\ No newline at end of file