Hi,
I ve got a vendor MSI and it leaves by uninstall the INSTALLDIR folder. Well, no problem, one custom action and the problem is gone like by hundred other MSIs.

But the problem is, it doesnt work. meanwhile I tried everything... I guess.

As WMI gives me error code 15, eventlogger tells me by VBS Path doesnt exist or Permission denid. The path is correct and the scripts run without problems under my account and with other MSI.

I tried following scripts:
Dim arrFolders()
Dim objWMIService
intSize = 0

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

objWMIService.Security_.ImpersonationLevel = 3
objWMIService.Security_.privileges.addasstring "SeDebugPrivilege", True

strFolderName = "C:\Program Files\pipc\Procbook\"
strFolderName = left(strFolderName, len(strFolderName)-1)
MSGBOX strFolderName

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
MSGBOX errResults
Next
Next

-------------------------------------------

dim filesys
dim fso
set fso = CreateObject ("Scripting.FileSystemObject")

if fso.folderexists(Session.Property("CustomActionData")) then
Call fso.DeleteFolder(Session.Property("CustomActionData"),true)
end if
Set fso = Nothing

--------------------------------------------------------------

On Error Resume Next

dim filesys
dim demofolder
dim installdir
dim fso
set fso = CreateObject ("Scripting.FileSystemObject")
demofolder = Session.Property("CustomActionData")
demofolder = left(demofolder, len(demofolder)-1)

if fso.FolderExists(demofolder) then
Call fso.DeleteFolder(demofolder,true)
end if
Set fso = Nothing



All these work (I know that the first is hardcoded ;))

As somebody please any tip, I mean it can be so difficult to delete an empty folder (yes, it is really empty)

Thx
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
It could be to do with the sequencing of the Custom Action. Try running it as Deferred execution in a System Context.....
Answered 08/06/2008 by: captain_planet
Second Degree Brown Belt

Please log in to comment
0
Was there some reason why you couldn't use the RemoveFiles table? It's perfectly possible to delete folders using it. http://msdn.microsoft.com/en-us/library/aa371199(VS.85).aspx
Answered 08/06/2008 by: VBScab
Red Belt

Please log in to comment
0
As Ian says, the RemoveFile table can be used most of the time.
I've found VBscript to be overly complex and more trouble than it's worth for this kind of task. If you've got Wise, WiseScript is much easier to work with for little code snippets.
Answered 08/06/2008 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
Hi,
yes, I cant use the RemoveFile Table because it doesnt work neither. The crazy thing is that at this point of the uninstallation the folder is already emtpy and can be deleteted without problems.
I run, well the system run the vbs in deferred execution in a System Context where I receive this different errors with the different scripts.

Its also the first time that something strange happend to me.

Can u please tell me maybe another solution? JS, BAT (rd /q /s [INSTALLDIR]?
Answered 08/06/2008 by: mac-duff
Second Degree Blue Belt

Please log in to comment
0
ORIGINAL: macduff
yes, I cant use the RemoveFile Table because it doesnt work neither.
Huh? I have innumerable MSIs which use the table to remove folders. If your package doesn't work, you have something set up incorrectly. You must have heard the acronym 'KISS'? (No offence, BTW)
Answered 08/06/2008 by: VBScab
Red Belt

Please log in to comment
0
its possible that something is set wrong, as I told it is a vendor MSI which is totally shitty. I mean I dont know much about MSI but these people know nothing.... It has no structure etc.

But back to the topic, I also checked the sequence and the sequence removefile is called, finally some other files are removed by this. But something seems to block the installdir because at least vbs works in other packages.....
Answered 08/06/2008 by: mac-duff
Second Degree Blue Belt

Please log in to comment
0
Sounds like something is locking the folder thus preventing it from being removed.
Answered 08/06/2008 by: AngelD
Red Belt

Please log in to comment
0
ng is locking the folder thus preventing it fro

do u know a method how to figure this exactly out?
Answered 08/06/2008 by: mac-duff
Second Degree Blue Belt

Please log in to comment
0
well, I tried the tool unlocker and it tells me msiexec is accessing this folder. after I unlock the folder the msi automaticlly removes it.
any ideas?
Answered 08/06/2008 by: mac-duff
Second Degree Blue Belt

Please log in to comment
0
I use the below script using the "call vbscript from embedded code" action and so far it has not failed me. In Wise Package Studio I place it in Execute Deferred under the "Remove Folders" line with the below If-Then statement:

If REMOVE~="ALL" Then
call vbscript from embedded code
End

'========vbscript=====
On Error Resume Next
Dim objFSO, strFolder1

'variable for the folder to delete i.e "c:\program files\Mozilla Firefox"
strFolder1="FolderName"

set objFSO=CreateObject("Scripting.FileSystemObject")

'delete command
objFSO.DeleteFolder(strFolder1) ,True
Set objFSO=Nothing
'======end script======
Answered 09/09/2008 by: tneubauer
Senior Yellow Belt

Please log in to comment
0
Hi Guys,

Want to put light to discussion.

Topic : Have to delete a folder from Vendor Msi

To the above topic there are basically two effective method of resolving the problem
1. Using Script.
2. Using RemoveFile Table


If still does not work mean you dont have to worry at all you can Ignore. if it is a Vendor MSI
If its not an not an Vendor MSI i dont think you would get the problem for deleting folder after Uninstallation.
Answered 10/28/2008 by: sami.msi
Yellow Belt

Please log in to comment
0
ORIGINAL: sami.msi
If still does not work mean you dont have to worry at all you can Ignore. if it is a Vendor MSI
If its not an not an Vendor MSI i dont think you would get the problem for deleting folder after Uninstallation.
Eh?

- How do you come to the conclusion that, just because it's a vendor MSI, one can ignore the fact that it doesn't remove file(s) or folder(s)?
- Why do you think one wouldn't come across the problem with one's own MSIs, particularly if it's a locked file problem?
- Why resurrect a thread which is clearly dead?
Answered 10/28/2008 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity