How to specify <SecureCustomProperties Property=“PROP1;PROP2”/> in wix .wxs file

Deadly 提交于 2021-02-10 10:43:49

问题


I want to specify property as restricted property in Wix installer, in wix .wxs file.

  <Property Id="PROP1">
     <RegistrySearch Id="Prop1"
                     Root="HKLM"
                     Key="SYSTEM\CurrentControlSet\Services\mysvc"
                     Name="installers"
                     Type="raw" />
  </Property>
  <Property Id="PROP2">
     <RegistrySearch Id="Prop2"
                     Root="HKLM"
                     Key="SYSTEM\CurrentControlSet\Services\mysvc"
                     Name="DisplayName"
                     Type="raw" />
  </Property>

Any idea?

Wanted to make PROP1, PROP2 private / secured.

Tried with making them as lowercase but RegistrySearch doesn't accept it:

error CNDL0012 : The Property/@Id attribute's value, 'Prop1', cannot contain lowercase characters.

Since this is a search property, it must also be a public property. This means the Property/@Id value must be completely uppercase.


回答1:


I believe you need to set the attibute Secure="yes" for the Property element in order for the property in question to be added to the SecureCustomProperties list in your compiled MSI file.

Sample:

<Property Id="MYPROPERTY1" Secure="yes" Value="SomeValue" /> 
<Property Id="MYPROPERTY2" Secure="yes" Value="SomeOtherValue" /> 

The resultant SecureCustomProperties value in the compiled MSI (with two auto-generated properties as well): MYPROPERTY1;MYPROPERTY2;WIX_DOWNGRADE_DETECTED;WIX_UPGRADE_DETECTED

Your Case:

So in your case something like the below (I set the property value to 0 in case the registry search finds nothing - then I have a default value):

<Property Id="PROP1" Secure="yes" Value="0" >
   <RegistrySearch Id="Prop1"
                   Root="HKLM"
                   Key="SYSTEM\CurrentControlSet\Services\mysvc"
                   Name="installers"
                   Type="raw" />
</Property>

The SecureCustomProperties list all the properties that can be sent to deferred mode - which runs elevated - when the installing user is not an administrator, but a standard users who is installing with elevated rights. For a good technical overview of the issue, maybe check out: Restricted Public Properties.


Digression:

And now, the mandatory digression: there was a case a while back when I needed to be able to override the value of SecureCustomProperties myself for some reason - rather than having it auto-generated based on all the properties with the Secure="yes" flag set.

For my life I cannot remember the particulars of the reasoning behind the need right now. Maybe Chris or Phil will remember / know of similar cases. I think it related to properties being added auto-magically to my MSI by WiX, but they were not set secured and I needed to make them secure in order to reliably access their values in deferred mode. I don't remember what WiX feature it related to.



来源:https://stackoverflow.com/questions/49768742/how-to-specify-securecustomproperties-property-prop1prop2-in-wix-wxs-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!