PDA

View Full Version : Appsearch



cg8189
07-23-2002, 02:03 PM
Hi,

I'm having a problem with an appsearch. I am looking for an existing file that i know is installed on the computer so i can read a setting out of the file. I then set the path to the file into a property using a system search for the file. The problem is that when i use install script to read the property i get \0 returned.

In the System Search wizard these are the parameters i setup.

The first dialog i selected "Folder path, by searching for a specific file in all drives".

Second dialog = File Name: Mygaitbrowser.exe & Number of subfolder levels to search = 4

Third dialog = EXISTINGINSTALLPATH is the property i want to store it in and "Just store the value in the property" is the option i have chosen.

I have 2 installscript functions that do the work that i need to.

The first function reads the EXISTINGINSTALLPATH and tries to open a file in the directory to read the settings and store it into EXISTINGKEY property. I have the upgrade table setup to remove any existing installs, but i want the first function to happen before the install removes the older program so that it can read the text file first. The second function takes the value of the EXISTINGKEY property and writes it down to the file after the install is complete.

The second function seems to work ok because i ran a test by setting the value of the EXISTINGKEY property in the table itself and it wrote it to the file correctly.

The two functions are below.

This is the first function:

function FnGetExistingKey()
object objfso;
object objtextstream;
string strexistingkey;
string strinipath;
long lnbuffer;
begin
strexistingkey = "";
strinipath = "";
lnbuffer = 0;

//Set the file system object
set objfso = CreateObject("Scripting.FileSystemObject");

//Call get property to get buffer size
MsiGetProperty(ISMSI_HANDLE, "EXISTINGINSTALLPATH", strinipath, lnbuffer);

//Add one for null terminator
lnbuffer ++;

//Resize the string to equal the buffer
Resize(strinipath, lnbuffer);

//Call to get the real value
MsiGetProperty(ISMSI_HANDLE, "EXISTINGINSTALLPATH", strinipath, lnbuffer);

//strinipath = "testsettings";

//Set property for now
MsiSetProperty(ISMSI_HANDLE, "EXISTINGKEY", strinipath);

//set objtextstream = objfso.OpenTextFile(TARGETDIR ^ "settings.ini");

//objtextstream.Close();

end;


This function is incomplete in that i don't actually read the file. For now it just sets the EXISTINGKEY property to the value in EXISTINGINSTALLPATH.

This is the second function:

function FnSetExistingKey()
object objfso;
object objtextstream;
string strexistingkey;
long lnbuffer;
begin
strexistingkey = "";
lnbuffer = 0;

//Set the file system object
set objfso = CreateObject("Scripting.FileSystemObject");

//Call get property to get buffer size
MsiGetProperty(ISMSI_HANDLE, "EXISTINGKEY", strexistingkey, lnbuffer);

//Add one for null terminator
lnbuffer ++;

//Resize the string to equal the buffer
Resize(strexistingkey, lnbuffer);

//Call get property to get buffer size
MsiGetProperty(ISMSI_HANDLE, "EXISTINGKEY", strexistingkey, lnbuffer);

set objtextstream = objfso.OpenTextFile(TARGETDIR ^ "settings.ini", 8, TRUE);

objtextstream.writeline("key=" ^ strexistingkey);

objtextstream.close();

end;

I have used events to schedule these functions to run. The first function is setup to run on OnFirstUIAfter(). And the second is set to run after the program files are installed.

So let me restate the problem. I have a Appsearch setup that should set the EXISTINGINSTALLPATH property so that the first function can read the settings from a file. This property is never getting set. Am i supposed to schedule an APPSEARCH action? When i created this project the APPSEARCH action was already shown in the Sequence tables.

Also i have another question. I am using the file system object to read and write to a text file. How do i get this to work on comptuers that don't have the file system object preloaded. I read somehwere to include a dll and that the scripting engine would do the rest. But i am a little confused on where to include this dll.

Thanks

Corey Gaspard

RobertDickau
07-23-2002, 03:02 PM
This thread might have some relevant information: http://community.installshield.com/showthread.php?s=&threadid=98404... (But you shouldn't have to add the AppSearch action to either sequence; it's included by default.)

cg8189
07-23-2002, 03:29 PM
Thanks for the reply.

I checked out the link you sent me and it did have some information i think i can use. But i did make a mistake in my first post. I posted that the first function is being called on OnFirstUIAfter() event. I think that this is wrong. I need to read and set the property before it removes the existing installation of the program. What event should i use to call my function then?

Thanks again

Corey

RobertDickau
07-24-2002, 08:15 AM
OnMaintUIBefore, perhaps?