If you need to delete leftovers from a program during uninstall / removal of an MSI Package, go ahead reading this post.
- Add this VBS Script to the Binary Table and call it DeleteFolderVbs (Column Name)
- Add the DeleteFolderVbs (Action) with Type 6 to the CustomAction Table
- Add the Action DeleteFolderVbs with Condition set to REMOVE=”ALL” to the InstallExecuteSequence with Sequence set to 6500
'========================================================================== ' NAME: DeleteDirectory.vbs ' ' AUTHOR: www.christiano.ch ' DATE : 20100811 (YYYYMMDD) ' ' COMMENT: removes directory ' ' USAGE / Syntax: DeleteDirectory.vbs ' ' CHANGE HISTORY: ' ......................................................................... ' DATE of Change Who What ' ------------------------------------------------------------------------- ' 20100811 Christian Muggli Created '========================================================================== Option Explicit On Error Resume Next ' Constants ' msiMessageType Public Const msiMessageTypeFatalExit = &H00000000 '// Premature termination, possibly fatal out of memory. Public Const msiMessageTypeError = &H01000000 '// Formatted error message, [1] is message number in Error table. Public Const msiMessageTypeWarning = &H02000000 '// Formatted warning message, [1] is message number in Error table. Public Const msiMessageTypeUser = &H03000000 '// User request message, [1] is message number in Error table. Public Const msiMessageTypeInfo = &H04000000 '// Informative message for log, not to be displayed. Public Const msiMessageTypeFilesInUse = &H05000000 '// List of files in use that need to be replaced. Public Const msiMessageTypeResolveSource = &H06000000 '// Request to determine a valid source location. Public Const msiMessageTypeOutOfDiskSpace = &H07000000 '// Insufficient disk space message. Public Const msiMessageTypeActionStart = &H08000000 '// Start of action, ' own Public Const strLogFilePrefix = "Custom Error Logging Framework: " WriteToMsiLog "Custom Script with Name: " & WScript.ScriptName & " started" Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject") Dim lRet, strFolder strFolder = Session.Property("TARGETDIR") WriteToMsiLog "determined TARGETDIR.. Resolved to: " & strFolder strFolder = MakePath(strFolder) If strFolder <> "" Then If oFSO.FolderExists(strFolder) Then WriteToMsiLog "Path: " & strFolder & " exists - will try to delete it.." lRet = oFSO.DeleteFolder(strFolder,True) WriteToMsiLog "Deleting Path: " & strFolder & " seems to be successful." End If End If Function WriteToMsiLog(strMessage) Dim objMessage Set objMessage = Session.Installer.CreateRecord(0) objMessage.StringData(0) = strLogFilePrefix & strMessage 'If Session.Property("CUSTDEBUG") <> "" Then MsgBox "Message: " & strMessage Session.Message msiMessageTypeInfo, objMessage End Function Function MakePath(strPath) If Right(strPath, 1) = "\" Then WriteToMsiLog "removing last backslash from path" strPath = Left(strPath, Len(strPath)-1) End If MakePath = strPath End Function