admin管理员组文章数量:1316336
I am trying to write a password string that is converted to a byte array by some algorithm to the registry where the type is reg_binary using Wix. But when doing so, I get an error as below: I am running the installer as an admin.
This is what I have. The variables are declared as follows, I can see DSN and UID in the registry after installing. But for PWD, the installer is giving an error as below.
<Property Id="DBDSN" Secure="yes" Value="PharmSpec_DSN"/>
<Property Id="DBUID" Secure="yes" Value="PharmSpecUsr"/>
<Property Id="DBPWD" Secure="yes" Hidden="yes" Value="220,65,202,153,221,86,197,178,212,16,105,233,16,129,21,97,151,207,163,60,183,45,111,47"/>
<Component Id="RegistryEntries_PharmSpec_ManualConfig" Guid="1C6A6F76-3898-40DE-AC0C-F7A59BECB471" KeyPath="yes" Directory="INSTALLDIR" Win64='yes'>
<!--<Condition>
<![CDATA[(WIX_UPGRADE_DETECTED) AND (DBDSN<>"-|-") AND (DBUID<>"-|-") AND (DBPWD<>"-|-")]]>
</Condition>-->
<RegistryKey Root="HKLM" Key="SOFTWARE\$(var.Manufacturer)" >
<RegistryKey Key ="PharmSpec" Id="PharmSpec_Key4" ForceCreateOnInstall="yes">
<RegistryKey Key="Database" Id ="Database_Key4" ForceCreateOnInstall="yes">
<util:PermissionEx User="Users" GenericAll="yes"/>
<RegistryValue Name="DSN" Value="[DBDSN]" Type="string" Action='write'/>
<RegistryValue Name="UID" Value="[DBUID]" Type="string" Action="write"/>
<RegistryValue Name="PWD" Value="[DBPWD]" Type="binary" Action="write"/>
</RegistryKey>
</RegistryKey>
</RegistryKey>
</Component>
The component is referred as,
<Feature Id='Complete' Title='$(var.ProductFullName)' Description='!(loc.IDPROP_SETUPTYPE_COMPLETE_DESC)' Display='expand' Level='1' >
<ComponentRef Id='RegistryEntries_PharmSpec_ManualConfig' />
</Feature>
When running the installer, I get an error as follows,
If I click Ignore, the product is installed and in the registry, I can see DSN and UID without PWD. Please help.
If I try the same in a C# app, it writes the password in the registry as reg_binary (please see the byPassword). I want to do the same in Wix.
public static bool WriteDatabaseInfoToRegistry(string szUserName, string szPassword, string szDSN)
{
bool bSuccess = false;
byte[] byPassword = null;
try
{
//Write the information to the registry
Registry.SetValue(PHARMSPEC_REGISTRY_KEY, "UID", szUserName);
Registry.SetValue(PHARMSPEC_REGISTRY_KEY, "DSN", szDSN);
if (HUATripleDES.Encrypt(szPassword, out byPassword) == true)
{
Registry.SetValue(PHARMSPEC_REGISTRY_KEY, "PWD", byPassword);
bSuccess = true;
}
}
catch (Exception ex)
{
bSuccess = false;
throw ex;
}
return bSuccess;
}
Edit
I tried converting byte array to hex string and modified the property like follows: but still it's giving the same error.
<Variable Name="Dbpwd" Value="DC-41-CA-99-DD-56-C5-B2-D4-10-69-E9-10-81-15-61-97-CF-A3-3C-B7-2D-6F-2F"/>
I am trying to write a password string that is converted to a byte array by some algorithm to the registry where the type is reg_binary using Wix. But when doing so, I get an error as below: I am running the installer as an admin.
This is what I have. The variables are declared as follows, I can see DSN and UID in the registry after installing. But for PWD, the installer is giving an error as below.
<Property Id="DBDSN" Secure="yes" Value="PharmSpec_DSN"/>
<Property Id="DBUID" Secure="yes" Value="PharmSpecUsr"/>
<Property Id="DBPWD" Secure="yes" Hidden="yes" Value="220,65,202,153,221,86,197,178,212,16,105,233,16,129,21,97,151,207,163,60,183,45,111,47"/>
<Component Id="RegistryEntries_PharmSpec_ManualConfig" Guid="1C6A6F76-3898-40DE-AC0C-F7A59BECB471" KeyPath="yes" Directory="INSTALLDIR" Win64='yes'>
<!--<Condition>
<![CDATA[(WIX_UPGRADE_DETECTED) AND (DBDSN<>"-|-") AND (DBUID<>"-|-") AND (DBPWD<>"-|-")]]>
</Condition>-->
<RegistryKey Root="HKLM" Key="SOFTWARE\$(var.Manufacturer)" >
<RegistryKey Key ="PharmSpec" Id="PharmSpec_Key4" ForceCreateOnInstall="yes">
<RegistryKey Key="Database" Id ="Database_Key4" ForceCreateOnInstall="yes">
<util:PermissionEx User="Users" GenericAll="yes"/>
<RegistryValue Name="DSN" Value="[DBDSN]" Type="string" Action='write'/>
<RegistryValue Name="UID" Value="[DBUID]" Type="string" Action="write"/>
<RegistryValue Name="PWD" Value="[DBPWD]" Type="binary" Action="write"/>
</RegistryKey>
</RegistryKey>
</RegistryKey>
</Component>
The component is referred as,
<Feature Id='Complete' Title='$(var.ProductFullName)' Description='!(loc.IDPROP_SETUPTYPE_COMPLETE_DESC)' Display='expand' Level='1' >
<ComponentRef Id='RegistryEntries_PharmSpec_ManualConfig' />
</Feature>
When running the installer, I get an error as follows,
If I click Ignore, the product is installed and in the registry, I can see DSN and UID without PWD. Please help.
If I try the same in a C# app, it writes the password in the registry as reg_binary (please see the byPassword). I want to do the same in Wix.
public static bool WriteDatabaseInfoToRegistry(string szUserName, string szPassword, string szDSN)
{
bool bSuccess = false;
byte[] byPassword = null;
try
{
//Write the information to the registry
Registry.SetValue(PHARMSPEC_REGISTRY_KEY, "UID", szUserName);
Registry.SetValue(PHARMSPEC_REGISTRY_KEY, "DSN", szDSN);
if (HUATripleDES.Encrypt(szPassword, out byPassword) == true)
{
Registry.SetValue(PHARMSPEC_REGISTRY_KEY, "PWD", byPassword);
bSuccess = true;
}
}
catch (Exception ex)
{
bSuccess = false;
throw ex;
}
return bSuccess;
}
Edit
I tried converting byte array to hex string and modified the property like follows: but still it's giving the same error.
<Variable Name="Dbpwd" Value="DC-41-CA-99-DD-56-C5-B2-D4-10-69-E9-10-81-15-61-97-CF-A3-3C-B7-2D-6F-2F"/>
Share
Improve this question
edited Feb 9 at 22:24
halfer
20.3k19 gold badges109 silver badges202 bronze badges
asked Jan 29 at 10:20
nikhilnikhil
1,7483 gold badges26 silver badges62 bronze badges
1 Answer
Reset to default 0Off the top of my head, I'm pretty sure this code here:
<util:PermissionEx User="Users" GenericAll="yes"/>
Is only granting access to logged in users to the registry key. The Windows Installer runs as SYSTEM so it doesn't end up with permissions to write to the key. Try granting all rights to SYSTEM, too.
本文标签: cWix write byte array binary value to registryStack Overflow
版权声明:本文标题:c# - Wix write byte array binary value to registry - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742003686a2411531.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论