How do I remove a file or a folder during installation?AnswerThe first step in removing a file or a folder is finding it's path. For this you can use a "New Search" or a "New File Search" in the Search page. Find the path of a folderThis can be done by following these steps:
The property used by the search ("MY_FOLDER") will contain the path to the folder (if it has been found). Removing a folderUnder normal circumstances a folder will be uninstalled automatically. However, if it contains resources which were not created by the installation package, the folder will not be removed. If you know the files which remain you can use File Removal Operations to remove all the files in the folder. However, if you don't know what the folder will contain, you can use a custom action: Function removeDir()
Dim pathToFolder, smallPath
Set objFS = CreateObject("Scripting.FileSystemObject")
pathToFolder = Session.Property("MY_FOLDER")
smallPath=Left(pathToFolder,Len(pathToFolder)-1)
If (objFS.FolderExists(smallPath)) then
objFS.DeleteFolder smallPath, true
End if
End FunctionThis code can be pasted into a .VBS file which can be added as an Attached custom action. You can execute this custom action whenever you want by scheduling it under a standard action ("InstallFinalize" for example).
Find the folder which contains a fileIn order to find the path of the folder which contains your file, you first need to find the file. This can be done by following these steps:
The property used by the search ("MY_FILE") will contain the path to the file (if it has been found). In order to obtain the path of the folder which contains this file, you can use a custom action: Dim path
path=Session.property("MY_FILE")
smallPath=Left(path,InStrRev(path,"\")-1)
smallPath=Left(path,InStrRev(smallpath,"\"))
Session.property("MY_FILE")=smallPath
Remove a fileOnce you have the path of the folder which contains your file you have two options for removing it:
If you use a file copy/move operation you can follow these steps:
| |
|
| Privacy Policy | Windows Installer | Search Engine Ranking | Link Analyzer | ||
| © 2002 - 2008 Caphyon Ltd. Trademarks belong to their respective owners. All rights reserved. | ||