Search and Delete file - Advanced Installer Community

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!

jledhead
Posts: 9
Joined: Thu May 08, 2008 1:22 pm

Search and Delete file

I am having a problem doing a search for a file and then deleting it. I have the enterprise version. I can create the search and test it and it runs fine, but I can't seem to figure out where to use that search, so I can have the installer search for the file and then delete it.

Any help is appreciated.
jledhead
Posts: 9
Joined: Thu May 08, 2008 1:22 pm

Re: Search and Delete file

from a support email
This can be done by following these steps:
- go to the "Search" page and create a search for a file (for example "MY_SEARCH")
- create a .VBS file on the disk and paste this code in it:

Dim path
path=Session.property("MY_SEARCH")
smallPath=Left(path,InStrRev(path,"\")-1)
smallPath=Left(path,InStrRev(smallpath,"\"))
Session.property("MY_SEARCH")=smallPath

- this VBScript code will eliminate the filename from the result of the search, leaving only the path of the folder which contains it
- go to the "Custom Actions" page and add the VBS file as an Attached custom action under "InstallExecuteSequence" -> "AppSearch" (you can see the "AppSearch" standard action by using the "Show Standard Action" button on the toolbar).
- go to the "Files and Folders" page and create a property-based folder by using the property of the search ("MY_SEARCH")
- create in this folder a File Removal operation and configure it to remove the file you want:
http://www.advancedinstaller.com/user-g ... ialog.html

You can read more about custom actions here:
http://www.advancedinstaller.com/user-g ... -page.html

Regards,
Cosmin
thanks AI support
jledhead
Posts: 9
Joined: Thu May 08, 2008 1:22 pm

Re: Search and Delete file

is there a way to have this delete multiple instances of a file instead of just the first one it finds?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Search and Delete file

Hi,

I'm afraid that this approach does not support deleting multiple instances of a file. However, you can create a custom action which finds and removes the files you want. For example, in VBScript you can use the GetFolder, SubFolders and FileExists methods to find the files and DeleteFile to remove them.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”