This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: How to get WindowsVolume path in installscript function
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 06, 2017
03:30 AM
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) :
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.
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.
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 09, 2017
10:50 AM
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
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
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 09, 2017
10:53 AM
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
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