Community Forums
Results 1 to 3 of 3

Thread: How to get WindowsVolume path in installscript function

  1. #1
    Join Date
    Oct 2017
    Posts
    3

    Question How to set DATABASEDIR using WindowsVolume variable 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) :

    Code:
    #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.
    Last edited by floriand; 10-06-2017 at 03:49 AM.

  2. #2
    Join Date
    Oct 2017
    Posts
    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;
    I have to use WINSYSDISK and FOLDER_COMMON_APPDATA in my case.
    I've found it there :
    Installscript Language Reference

  3. #3
    Join Date
    Oct 2017
    Posts
    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;

    I've found useful informations here
    http://helpnet.installshield.com/ins...fo_Example.htm

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •