We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

Cprint
Posts: 9
Joined: Wed Jun 20, 2007 2:16 pm

uninstall remove folders

http://advancedinstaller.com/forums/vie ... +uninstall

This above forum provided me with a lot to work with, however when I uninstall, the program is still fatal erroring and will not complete the uninstallation.

My script is designed to remove the installation direction, and then remove the folder above the installation directory. For example, in the case of

"Program Files / company-name / program-name "

I would want the script to uninstall the program-name folder first, and then if the company-name folder is empty, uninstall it next.

Currently, this is what my script looks like.

Code: Select all

Function removeInstallDir()
   Dim pathToFolder, smallPath
   Set objFS = CreateObject("Scripting.FileSystemObject")
   pathToFolder = Session.property("APPDIR")
   smallPath=Left(pathToFolder,Len(pathToFolder)-1)
   If (objFS.FolderExists(smallPath)) then
      objFS.DeleteFolder smallPath, true
   End if

   If Right(smallPath, 1) = "\" Then smallPath = Mid(smallPath, 1, Len(smallPath) - 1)
	smallPath = Mid(smallPath, 1, InStrRev(smallPath, "\") - 1)
	If ((objFS.GetFolder(smallPath).Files.Count = 0) & (objFS.getFolder(smallpPath).Folders.Count = 0)) then
		objFS.DeleteFolder smallPath, true
	End if

End Function


The steps to add it to the advanced installer project are as follows.

Custom Actions -> Add RemoveFolders -> Under RemoveFolders, Add Attached Custom Action -> set Function Name to removeInstallDir -> Add ExecuteCondition (Remove="ALL").

Is there any step I am missing?

Thanks

Jon
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi Jon,

The problem you encounter is because when Windows Installer expands the folder path, it adds an extra '\' at the end. This is why the script fails.

So you need to modify the script in order to remove the extra '\'. Also note that is no need to remove the second folder. You can let Windows Installer to remove it (if remains empty) be scheduling the custom action under "InstallExecuteSequence->Uninstall".

Regards,
Gigi
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”