cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
floriand
Level 3

How to get WindowsVolume path in installscript function

Hello,

I would like to change the default DATABASEDIR for my end-users dynamically.

Example :
For customer1, the default databasedir will be [WindowsVolume]MyDatabase
For customer2, the default databasedir will be [CommonAppDataFolder]SomeFolder\MyDatabase

End-users can change this path through the user interface dialog "DatabaseFolder".

I have created an installscript function as follows (i know that this function is not complete) :

#include "isrt.h"
#include "iswi.h"

function SetDatabaseDir(hMSI)
STRING svFolder;
NUMBER nvSize;
begin
nvSize = 256;
MsiGetProperty (hMSI, "WindowsVolume", svFolder, nvSize); // this doesn't work
// or MsiGetProperty (hMSI, "CommonAppDataFolder", svFolder, nvSize); // this doesn't work too
MsiSetProperty(hMSI, "DATABASEDIR", svFolder + "MyDatabase");
end;


This function is launched by a custom action that runs "After cost finalize" in the install exec sequence.

Is it possible to do that ? what am i doing wrong ?
Thanks in advance.
Labels (1)
0 Kudos
(2) Replies
floriand
Level 3

I've found it by myself

Here is the final code reading ini file

[CODE]function SetDatabaseDir(hMSI)

#define MYSECTION "ProductConfiguration"
#define MYKEY "QuizzBoxDataDefaultFolder"

STRING svFolder;
STRING svCurrentDir;
STRING svIniFile;
begin
try
svCurrentDir=SRCDIR;
if svCurrentDir != "" then
svIniFile=svCurrentDir + "\\QB_Installshield.ini";
if Is(FILE_EXISTS,svIniFile) then
//MessageBox(svCurrentDir, INFORMATION);
GetProfString(svIniFile,MYSECTION,MYKEY,svFolder);

StrReplace(svFolder,"[WINSYSDISK]", WINSYSDISK, 0);
StrReplace(svFolder,"[FOLDER_COMMON_APPDATA]", FOLDER_COMMON_APPDATA, 0);

MsiSetTargetPath(hMSI, "DATABASEDIR", svFolder + "QuizzboxData" + "\\");
endif ;
endif;
catch
//MessageBox("SetOfficeBitnessProperty Error \n" + Err.Number + "\n" + Err.Description + "\n" + Err.LastDllError , SEVERE);
endcatch;
end;[/CODE]

I have to use WINSYSDISK and FOLDER_COMMON_APPDATA in my case.
I've found it there :
Installscript Language Reference
0 Kudos
floriand
Level 3

I have found it by myself

Here is the final code (reading ini file in the install.exe folder)

[CODE]function SetDatabaseDir(hMSI)

#define MYSECTION "ProductConfiguration"
#define MYKEY "QuizzBoxDataDefaultFolder"

STRING svFolder;
STRING svCurrentDir;
STRING svIniFile;
begin
try
svCurrentDir=SRCDIR;
if svCurrentDir != "" then
svIniFile=svCurrentDir + "\\QB_Installshield.ini";
if Is(FILE_EXISTS,svIniFile) then
//MessageBox(svCurrentDir, INFORMATION);
GetProfString(svIniFile,MYSECTION,MYKEY,svFolder);

StrReplace(svFolder,"[WINSYSDISK]", WINSYSDISK, 0);
StrReplace(svFolder,"[FOLDER_COMMON_APPDATA]", FOLDER_COMMON_APPDATA, 0);

MsiSetTargetPath(hMSI, "DATABASEDIR", svFolder + "QuizzboxData" + "\\");
endif ;
endif;
catch
//MessageBox("SetOfficeBitnessProperty Error \n" + Err.Number + "\n" + Err.Description + "\n" + Err.LastDllError , SEVERE);
endcatch;
end;[/CODE]


I've found useful informations here
http://helpnet.installshield.com/installshield22helplib/Subsystems/installshield22langref/installshield22langref.htm#CSHID=helplibrary%2FLangrefGetSystemInfo_Example.htm|StartTopic=helplibrary%2FLangrefGetSystemInfo_Example.htm
0 Kudos