SamuelB
Posts: 4
Joined: Mon Oct 22, 2007 3:32 am

Problem passing search results to vb script

Hello,

I am relatively new to advanced installer. I am trying to run a vb script that will delete certain files from the results of a file search.

Reading up on your forum I have avoided the common pitfalls:
-- I use: pathToFile = Session.Property("SEARCH_RES_1")
-- Setting the vb script custom action to run with immediate execution

The path always return a blank line when addressing the search result. I have tried using other session properties such as "APPDIR" and I can read these fine. Just not search results.

My code is:

Function removeFiles()
Dim pathToFile
Set objFS = CreateObject("Scripting.FileSystemObject")
pathToFile = Session.Property("SEARCH_RES_1")

If (objFS.FileExists(pathToFile)) then
objFS.DeleteFile pathToFile, true
End if
End Function


My second problem is what to do if the search result locates more than one instance of the same file? How do I address each result individually and hence delete each instance of the same file?

Looking on the forum I have read similar posts which are pointed to other examples which seem to incorporate a session database, however they do not seem to address search results.

Thanks for any help,
Sam.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi Sam,

Please make sure that the result of the search is not always empty. You can test a search in the "Search" page by using the "Test" button. Also make sure you schedule the custom action after "AppSearch" standard action.
My second problem is what to do if the search result locates more than one instance of the same file? How do I address each result individually and hence delete each instance of the same file?
A search always returns only one result. The first that is found.

Let me know if the problem still persist.

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

Return to “Common Problems”