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

Edinting ini files


6 replies to this topic

sidew

sidew
  • Members
  • 10 posts

Posted 27 February 2001 - 09:38

We have developed a nt service, but, one component require a ini file, with older IS (5.1) these file is edited in certain fields during setup process. For compatibility issues, we porting all older setup on Windows Installer, but we can't edit the ini file.

In some tests, we can write de ini files, but the other sections disappears or the ini files is copied but the setup can't write the changes in the opportune sections.

Any suggestion?

Thank in Advance.


rflum

rflum
  • Full Members
  • 40 posts

Posted 28 February 2001 - 18:52

Here's a function I wrote to do the same thing.  I put this in the Execute sequence just before the last standard function, when I know my ini file has been transferred to the hard drive.


///////////////////////////////////////////////////////////////////////////////
//                                                                          
// Function:  _SetXXXiniTarget
//                                                                          
//  Purpose:  Replace xxx.ini <YOUR_MACRO_NAME> macro
//         with real targetdir if xxxxxxxxxxxxxx.
//                                                                          
///////////////////////////////////////////////////////////////////////////////
function _SetXXXiniTarget(hInstall)  

  SHORT    shResult;
  LONG     lvSize;
  STRING   szReferenceFile;
  STRING   szFileName;
  STRING   szSectionName;
  STRING   szKeyName;
  STRING   szOrigValue;
  STRING   szReplaceValue;
  STRING   svValue;
  STRING   svInstalledFilePath;
 
begin

  //  We're in the Execute sequence, and globals don't carry over
  //  from the User Interface sequence.
  lvSize = MAX_STRING_SIZE;
  MsiGetProperty(hInstall, "_MY_PRODUCT_INFO", svValue, lvSize);
  if (lvSize > 0) then
     gbIsSomeInfo = TRUE;
  endif;
  lvSize = MAX_STRING_SIZE;
  MsiGetProperty(hInstall, "_MORE_PRODUCT_INFO", svValue, lvSize);
  if (lvSize > 0) then
     gbIsSomeMoreInfo = TRUE;
  endif;

  //  Replace macro with real targetdir in xxx.ini if gbIsSomeInfo is true.
  if ( gbIsSomeInfo = TRUE) then
     if (FindFile( WINDIR, @_YOUR_INI_FILE, szFileName) = 0) then
        szSectionName = @_YOUR_SECTION_NAME;
        szKeyName = @_YOUR_KEY_NAME;
        szOrigValue = @_TARGETDIR_MACRO + "\\\\" + @_YOUR_KEY_VALUE;
        szReplaceValue = TARGETDIR ^ @_SUBFOLDER_NAME ^ @_YOUR_KEY_VALUE;
        ReplaceProfString (szFileName, szSectionName, szKeyName, szOrigValue, szReplaceValue);
     endif;
  endif;
end;


sidew

sidew
  • Members
  • 10 posts

Posted 06 March 2001 - 11:00

Thank you for suggestion.

I have tried using the MsiGetProperty functions, but my function doesn't work:

If i put the function before Execute Action , as you suggested, i got a 2762 error, if i put before WriteIniValues, it seem my function never called.

The condictions are: NOT Installed AND NOT PATCH

The function is following:
///////////////////////////////////////////////////////////////////////////////
function SetupINIfile(hInstall)  
   STRING svIpAddress;
STRING svIpPort;
STRING szMsg;
STRING szTitle;
STRING svClientName;
   STRING svOldIpAddress;
   STRING svOldClientName;
   string svBuf;
NUMBER nvType;
NUMBER nvByte;
NUMBER nResult;
LONG   lSize;

begin
   lSize = 2048;
   
   MsiGetProperty(hInstall, "InstallPath", svBuf, lSize);
   
   TARGETDIR = svBuf;
   
   
nResult = RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
 // ask host
 nResult = GetProfString(TARGETDIR ^ "invision.ini" ,
 "InVision" ,
 "Servers" ,
 svOldIpAddress);
 
 nResult = GetProfString (TARGETDIR ^ "invision.ini" ,
 "REQUESTER" ,
 "MACHINE_NAME" ,
 svOldClientName );
 
 svIpAddress = "127.0.0.1";
 svIpPort = "6717";
 szTitle = "RapiAgent Service Setup";
 szMsg = "RapiAgent Service Configuration ";
 szMsg = szMsg + "Insert the IP address of RBS8 Server to listen";
 
 nResult = SdShowDlgEdit2 (  szTitle,
 szMsg ,
 "RBS8 Server IP Address" ,
 "Port",
 svIpAddress,
 svIpPort );
 
 nResult = ReplaceProfString ( TARGETDIR ^ "invision.ini" ,
 "InVision" ,
 "Servers" ,
 svOldIpAddress,
 "T:" + svIpAddress + ":"+ svIpPort );
 
 svClientName = svOldClientName;
 szMsg = "Please insert a unique name for this RapiAgent client. ";
 szMsg = szMsg + "This name must be unique for the server RBS8. We use as default the Computer Name";

nResult = SdShowDlgEdit1 ( szTitle,
szMsg,
"RapiAgent Client Name",
svClientName );

 nResult = ReplaceProfString ( TARGETDIR ^ "invision.ini",
   "REQUESTER",
   "MACHINE_NAME",
   svOldClientName,
   svClientName );
   
 nResult = ReplaceProfString ( TARGETDIR ^ "invision.ini",
   "CP_NETBIOS",
   "NODENAME",
   svOldClientName,
   svClientName );
 
 
  return 0;
 
end;


Where is wrong?

TIA


rflum

rflum
  • Full Members
  • 40 posts

Posted 08 March 2001 - 21:31

If you put this CA before ExecuteAction, you put it in
the User Interface sequence, not the Execute sequence.  This won't work, because you have to copy the ini file to the PC before you can modify it.  Put it in the Execute sequence right before RemoveExistingProducts.
   Rob

rflum

rflum
  • Full Members
  • 40 posts

Posted 03 April 2001 - 15:23

Hi, Aldo,
 Did this work for you?
  Rob

sidew

sidew
  • Members
  • 10 posts

Posted 03 April 2001 - 15:28

Yes, it works.

Thanks you for yoyr suggestion.

Sorry for delay, but I 'm very busy.