Change the RootDrive in Xml with the path specified in .ini file
Asked Answered
W

1

0

I am working on WIX Installer. I am trying to read Directory path from .ini file to XML. I have to red the path and get the files installed to that particular path.

    <Property Id="ROOTDRIVE">
        <![CDATA[*value which is read from .ini file has to be passed here*]]>
    </Property>
    <Property Id="MY_PROPERTY">
      <IniFileSearch Id="myIniSearch" Name="localtest.ini" Section="ENVIRONMENT" Key="LocalDirectory" Type="raw">
        <DirectorySearch Id="SPIniFilePath" Path="C:\">
          <FileSearch Id="SPIniFile" Name="localtest.ini"/>
        </DirectorySearch>
      </IniFileSearch> />
   </Property>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir" >
      <Directory Id="myIniSearch">
        <Directory Id="INSTALLFOLDER" Name="!(bind.property.ProductName)" />
      </Directory>
   </Directory>
  </Fragment>

localtest.ini is the .ini file. It is in the C drive

    [ENVIRONMENT]
    LocalDirectory=D:\Ng

Files should get installed to the path specified in .ini file. Following I added CustonAction. Still it gets installed in C drive

    <Property Id="MY_PROPERTY" Secure="yes">
      <IniFileSearch Id="myIniSearch" Name="localtest.ini" Section="ENVIRONMENT" Key="LocalDirectory" Type="raw">
        <DirectorySearch Id="SPIniFilePath" Path="C:\">
          <FileSearch Id="SPIniFile" Name="localtest.ini"/>
        </DirectorySearch>
      </IniFileSearch> 
    </Property>
<CustomAction Id="MyAction.SetProperty" Return="check" Property="MyAction" Value="[MY_PROPERTY]" />
<InstallExecuteSequence>
  <Custom Action="MyAction.SetProperty" After="AppSearch" />
</InstallExecuteSequence>
<DirectoryRef Id='MY_PROPERTY'>
  <Directory Id='INSTALLDIR_SimpleWebApp' Name='SimpleWebApp' />
</DirectoryRef>
Wideangle answered 6/12, 2021 at 9:15 Comment(0)
F
1

From your code it looks like MY_PROPERTY will be set to the directory found in the ini file (if found). In this case, schedule a type 51 custom action (after AppSearch) that sets 'INSTALLFOLDER' to the value "[MY_PROPERTY]!(bind.property.ProductName)" if MY_PROPERTY is not empty.

(I believe you can drop the ROOTDRIVE and myIniSearch properties)

Fantast answered 7/12, 2021 at 18:15 Comment(2)
I have added the custom action. still it is getting installed in C drive and not in the path I specified in the .ini fileWideangle
I had placed .ini file in C: drive. I placed it in C:\Windows and it worked.Wideangle

© 2022 - 2024 — McMap. All rights reserved.