2016-02-01 97 views
2

我想在安裝過程中保存註冊表中的屬性值,並在下次安裝時讀取它。 描述here'記住屬性'模式和在RadioButtonGroup中使用的屬性

它基本上按預期工作我按照「注意財產」的模式,但我不能讓一個場景的工作:

  • 我運行安裝程序(屬性,都會存儲在註冊表中)
  • 我再次運行安裝程序而不在命令行上輸入屬性值
  • 我希望從註冊表中讀取屬性的值,但它被分配了默認值。

我想,我知道問題在哪裏:我已將「Value」分配給該屬性,而上面提到的示例聲明瞭「Remembered」屬性而沒有「Value」。在我的包中,我必須定義值,因爲我在RadioButtonGroup中使用UI元素中的屬性。如果我不申報財產的價值領域,我得到的編譯錯誤:

error LGHT0204 : ICE34: Property LOCATION (of RadioButtonGroup control LocationSelection.InstallationLocation) is not defined in the Property Table. 

任何人都可以給我一個提示如何管理呢?

+0

你應該發佈你的代碼。如果你確實聲明瞭屬性,那麼它將在屬性表​​中。看起來你可能以某種方式錯誤地宣佈了它。 – PhilDW

+0

否定的。我有財產申報'價值=「東西」' - 然後該軟件包編譯和按預期工作(除了我問的問題)。從屬性聲明中移除Value標記就足夠了,並且你得到ICE34。我想爲屬性賦值是強制性的,與RadioButtonGroup一起使用。這打破了閱讀默認設置。 – macmac

+0

好的 - 我最終使用3個屬性解決了這個問題:一個用於從/註冊表中讀取/存儲永久值,第二個用於在靜默安裝期間從命令行獲取值,以及第三個用於RadioButtonGroup的「有效」值。前兩個屬性沒有分配默認值,而「有效」一個 - 沒有。然後,通過CustomActions,我可以根據命令行和註冊表中的值來設置「有效」屬性。 – macmac

回答

2

這裏是解決方案草案:

自定義操作,以填補性能

<CustomAction Id='SaveCmdLineValueLocation' Property='CMDLINE_LOCATION' 
       Value='[LOCATION]' Execute='firstSequence' /> 
<CustomAction Id='SetFromCmdLineValueLocation' Property="EFFECTIVE_LOCATION" 
       Value='[CMDLINE_LOCATION]' Execute='firstSequence' /> 
<CustomAction Id='SetFromRegValueLocation' Property="EFFECTIVE_LOCATION" 
       Value='[REG_LOCATION]' Execute='firstSequence' /> 

執行序列assignes EFFECTIVE_LOCATION無論是從註冊表或者msiexec命令行:

<InstallExecuteSequence> 
     <Custom Action='SaveCmdLineValueLocation' Before='AppSearch'> 
     LOCATION 
     </Custom>  
     <Custom Action='SetFromCmdLineValueLocation' After='AppSearch'> 
     CMDLINE_LOCATION 
     </Custom> 
     <Custom Action='SetFromRegValueLocation' After='AppSearch'> 
     REG_LOCATION AND (NOT CMDLINE_LOCATION) 
     </Custom> 
</InstallExecuteSequence> 

屬性聲明:

<!-- Property used on command-line. --> 
<Property Id="LOCATION" Secure="yes"> 
</Property> 

<!-- Property used finally with ReadioButtonGroup. It must have Value assigned (required when used with RadioButtonGroup --> 
<Property Id="EFFECTIVE_LOCATION" Value="OFFICE" Secure="yes"> 
</Property> 

<!-- Read previous value from registy (from recent installation) --> 
<Property Id="REG_LOCATION" Secure="yes"> 
    <RegistrySearch Id="loc" Root="HKLM" Key="SOFTWARE\Company\Product" Type="raw" Name="LOCATION" Win64='yes'> 
    </RegistrySearch> 
</Property> 
+0

很好地工作。非常感謝。 –