PDA

View Full Version : Removing folders during uninstallation



yongyizhang
08-31-2006, 06:38 AM
Hello TsungH and everyone. I am a new user of InstallShield 11.5 Exp Edt. I have created a express project. Installation of our software works well. The problem is that 1 folder (which contains subfolders and files) can not be removed after the uninstallation.

I have read TsungH's earlier post and tried to use VBScript to created a Custom Action. However, it doesn't work. :(

I have pasted the VBScript below. VB is fresh for me....Could any one see any problem about this piece of VB code?

Many many Thanks!!!!!!!


-------------- VBScript ------------------
Dim arrFolders()
intSize = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

strFolderName = "C:\Program Files\FunnySoftware"

Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")

ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1

For Each objFolder in colSubfolders
GetSubFolders strFolderName
Next

Sub GetSubFolders(strFolderName)
Set colSubfolders2 = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")

For Each objFolder2 in colSubfolders2
strFolderName = objFolder2.Name
ReDim Preserve arrFolders(intSize)
arrFolders(intSize) = strFolderName
intSize = intSize + 1
GetSubFolders strFolderName
Next
End Sub

For i = Ubound(arrFolders) to 0 Step -1
strFolder = arrFolders(i)
strFolder = Replace(strFolder, "\", "\\")
Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name = '" & strFolder & "'")

For Each objFolder in colFolders
errResults = objFolder.Delete
Next
Next