Welcome to the Joint-Venture Blog from Fabio Cortesi and Stefan Jäger.
11.05.2009 - Fabio Cortesi
By default WISE can’t delete a folder structure with all files and subfolders. The technologie of MSI is designed to delete only these components by uninstalling, which were installed.
With the following VB-Script can do just that. It makes sense, that the script uses a property of the directory-table. The example uses the “JUNIPER” directory, which will be deleted by the script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | Option Explicit Dim WshShell,SystemFolder,Fso,strFolder, strFile, ret ' Set the property strFolder = GetAProperty("JUNIPER") ' Delete the last character at the end of the string ' -> example: C:\Programm Files\Test"\" ' For a correct deleting of a directory-property, ' the backslash at the end has to be deleted strFolder = Left(strFolder,Len(strFolder)-1) ' Environment variable reading set WshShell = CreateObject("WScript.Shell") set Fso=createobject("scripting.filesystemobject") ' Delete the folder If Fso.FolderExists(strFolder) Then ret = Fso.DeleteFolder (strFolder,True) End If Set WshShell = Nothing Set fso = Nothing ' Getting a property Function GetAProperty (PROPERTYNAME) dim szStringVal szStringVal = Session.Property(PROPERTYNAME) GetAProperty = szStringVal End Function |
The script must be implemented in the “immediate” section of the MSI-Script. In my example it has to be on the latest position – immediately before the completion of the installation.
Comments
Leave a comment