Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Integrating Session Properties into an InstallScript


12 replies to this topic

Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 13 February 2002 - 19:51

What is the process or function needed to pull Session Properties into an InstallScript.

I am currently using SetFileInfo to change the modified date on a file(s).  I need to get the value of INSTALLDIR into the script for the file location.

Can anyone help?

If so, GREATLY APPRECIATED!!!


pnunes

pnunes
  • Members
  • 13 posts

Posted 13 February 2002 - 21:55

MSIGetProperty - refer to documentation for syntax.

Sample:
   //Get value of CMDLINE property. This is to provide backward compatibility for old scripts
   nvSize = 1024;
   MsiGetProperty(hMSI,"CMDLINE",CMDLINE,nvSize);
   //Get value of SrcDir property. This is to provide backward compatibility for old scripts
   nvSize = 1024;
   MsiGetProperty(hMSI,"SourceDir",SOURCEPATH,nvSize);
   //Get value of SrcDir property. This is to provide backward compatibility for old scripts
   nvSize = 1024;
   MsiGetProperty(hMSI,"INSTALLDIR",TARGETDIR,nvSize);


Note that nvSize is set before each call. This is necessary since the function resets this value to the buffer size of the retrieved value. Subsequent calls may leave the buffer too small for the next value.

There is also MSISetProperty to go in other direction


Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 13 February 2002 - 22:27

Thanks, I was wondering what the nvSize was for.

I'll work with this.

Thanks!!!


Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 14 February 2002 - 15:05

Two more things.  First, how can I display a value of a variable during my script to ensure I have the correct values?  I would like to display the value of, lets say, svInstd which should grab INSTALLDIR through MsiGetProperty (for troubleshooting/development purposes).

The next thing I need to know is how to join two string variables to form one larger string.  For example:
   
    svInstd should equal the value of INSTALLDIR
    svDBDir will = an assigned value of a directory
                              which is present on all of our users
                              systems.  I'll call the directory DBTest
                              here.
   
I need to join these together to form a path to certain files such as C:\DBTest (Another quick question - is the backslash part of INSTALLDIR or do I have to add it the the value of svDBDir as "\DBTest"?).

I was thinking of assigning this path value to a variable called svFileLoc.

Then I would like to assign values such as:
FILE1 = svFileLoc + "any file name".

Then I will be changing the files date through:
SetFileInfo (FILE1, FILE_DATE, 0, NEW_FILE_DATE).

Also, there are many files in svFileLoc which I would like to change (date that is).  Can I use a wild card for the "any file name" above such as EXAM*.txt?

As you can probably tell, I'm not a 'coder' and I would GREATLY appreciate any pointers as to how to get this done.

As always, THANKS!



Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 14 February 2002 - 16:48

Also, is there an easy to read InstallScript tutorial/reference anywhere?  Skipping around in Help files can be tedious!

Thanks again!


Leigh Ravenhall

Leigh Ravenhall
  • Members
  • 269 posts

Posted 14 February 2002 - 23:32

When joining strings together to make a path/filename, use the ^ instead of + to join them.  The script then inserts the appropriate slashes to form a valid path.  If you do need to use a \ in your script, remember that InstallShield treats a \ as an escape character, so you have to put in \\.

With the SetFileInfo call, I don't think it will cope with multiple files.  You'll have to use a FindAllFiles loop.

Hope this helps a bit.


Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 19 February 2002 - 20:50

Thanks Leigh.  The info for joining strings and the "\" issue did the trick.  Now all I have to do is insert the FindAllFiles logic and get that to work, and I'll be set.

Thanks for the help!!!


Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 20 February 2002 - 15:52

Alright, I'm still having problems.  Here's the rundown:  I have 30+ files in the same directory (can use wildcard) to which I need to change the modified date to ensure they will be overwritten during the install (no need to worry about overwriting end user changes).

I have coded SetFileInfo and am able to change the modified date on a single file.  I can then copy that line and change the file name in the command to execute on an additional file.  What I don't want to do is to have 30+ SetFileInfo lines in the script.  If there is a new database file, I may forget to put its corresponding line in the script.

I was hoping to use FindAllFiles (as Leigh suggested) to find all, let's say, Test*.mdb files in a certain directory which I'll call C:\TEST.

I have looked at the documention and the FindAllFiles example from Help, but, I can't make heads or tails out of it.

I was wondering if there is a pretty straight forward way of doing this.

As always, THANKS for any info.

I love this site!!!


Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 20 February 2002 - 15:54

Also, I saw in the Help files/examples that there may be some considerations for using FindAllFiles on systems running under NT.

Is this a major concern?

Thanks again all!!


Leigh Ravenhall

Leigh Ravenhall
  • Members
  • 269 posts

Posted 20 February 2002 - 23:28

Cutting out all the other garbage from that example, this is the bit you need.

nResult = FindAllFiles (svDir, svFileSpec, svMatchingFileName, RESET);

   while(nResult = 0)
       // Run your SetFileInfo call
       SetFileInfo(svMatchingFileName,.......);

       // Find the next matching file name.
       nResult = FindAllFiles(svDir, svFileSpec, svMatchingFileName, CONTINUE);
   endwhile;

svDir is the directory that you wish to search
svFileSpec is the specification you wish to match

After this loop has run through, if you are targeting NT include this line:
FindAllFiles(svDir, svFileSpec, svMatchingFileName, CANCEL);

I think the cancel line is just to release some file/directory locks.

Any other problems, just post again.


Superfreak3

Superfreak3
  • Full Members
  • 437 posts

Posted 21 February 2002 - 13:59

We're targeting all Operating Systems.  Is it OK to have the following in a script that runs on all OSs or do I need a separate script for NT?

FindAllFiles(svDir, svFileSpec, svMatchingFileName, CANCEL);



Leigh Ravenhall

Leigh Ravenhall
  • Members
  • 269 posts

Posted 22 February 2002 - 00:53

That should be fine on other operating systems.  All you are doing is releasing the resources held by the FindAllFiles.

pnunes

pnunes
  • Members
  • 13 posts

Posted 26 February 2002 - 16:36

Regarding nvSize in the MsiGetProperty, this is critical since this sets the size of the buffer used to accept the string value from MSI. Set it to an appropriate size for the string you are receiving. Also, it must be reset every time you call MsiGetProperty. This is because Installshield will change that value to reflect the actual length of the string received. If you do not reset it to a value >= the new string, then the buffer may be too small. I have not had any problems using a nice large value like 1024 which should be suffiecient for any MSI properties.