Wix - Get user input to create a registry entry - wix

I need to create an installer that gets the user input to create a registry entry. I've looked into Wix tutorials and it's very clear how to install registry entries but I need the user to give some info(in this case it's an url) so that url can be used on the registry entry.
How can I do this?

Duplicate question!?
Please take a look at this answer if it helps: https://stackoverflow.com/a/20679626/1331719
Edit - slightly modifying the answer found in the link:
Start by adding this component, notice the property in Value [USERINPUT]
<DirectoryRef Id="INSTALLDIR">
<Component Id="RegistryEntries" Guid="{YOURGUID}">
<RegistryKey Root="HKLM" Key="Software\Company123\App123" Action="create">
<RegistryValue Type="string" Name="UserInput" Value="[USERINPUT]" />
</RegistryKey>
</Component>
</DirectoryRef>
Reference the component in your feature:
<Feature>
<ComponentRef Id="RegistryEntries" />
...
</Feature>
Get user input when you install using msiexec:
msiexec /i your.msi /qb+ USERINPUT="http://urlYouWantToStoreIn.Registry"
Check registry HKLM\Software\Company123\App123\UserInput, the url should be there.

Related

WIX registry key entry fails using Auto Generated GUID

Im using WIX 3.11.2 and when adding a registry key I get the following error:
“The Component/#Guid attribute's value '' is not valid for this component because it does not meet the criteria for having an automatically generated guid”*
I have created a ‘.wxs’ file which contains the following code that is failing:
<Fragment>
<ComponentGroup Id="myComponentGroup" Directory="TARGETDIR">
<Component Id="cmpRegUrlHandler" Guid="*">
<RegistryKey Root="HKCR" Key="HKEY_CLASSES_ROOT\myAppName\shell\open\command">
<RegistryValue Value="C:\Program Files\\myCompanyName\myProductName" KeyPath="yes" />
</RegistryKey>
</Component>
</ComponentGroup>
I run it using candel.exe/light.exe. However, light.exe gives me the above error.
Any help on this would be much appreciated.
You can't use Guid="*" for a component that has only a RegistryKey. You need to give it a real guid.

How can I remove a RegistryValue on uninstall without removing the parent RegistryKey with WIX?

If I use the follow code then nothing is removed on uninstall.
<DirectoryRef Id="INSTALLDIR">
<Component Guid="xyz" Id="instance_path" MultiInstance="yes">
<RegistryKey ForceCreateOnInstall="yes" Id="instance_path_reg" Key="Software\i-net software GmbH\i-net Test\Instances" Root="HKLM">
<RegistryValue Name="[INSTANCE_NUMBER]" Type="string" Value="[INSTALLDIR]"/>
</RegistryKey>
</Component>
</DirectoryRef>
If I replace ForceCreateOnInstall="yes" with ForceDeleteOnUninstall="yes" then all is removed on uninstall.
But I want only remove the RegistryValue of this instance. The values of other instances should not removed.
You could try using the RemoveRegistryValue and leave your current entries. It is a little messy but should get the job done.
http://wixtoolset.org/documentation/manual/v3/xsd/wix/removeregistryvalue.html
The problem was that the property INSTANCE_NUMBER was not set on uninstall. The uninstaller has try to delete a not existing key.

Wix registry key changing

I'm using a WiX installer file to edit a registry entry however when it's uninstalled I want it to be set do a default value of 0.
Here is the code I'm using to set it to 1.
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="PUT-GUID-HERE">
<RegistryKey Root="HKCU"
Key="Software\Microsoft\Windows\CurrentVersion\Policies\System"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer" Name="DisableTaskMgr" Value="1" KeyPath="yes"/>
</RegistryKey>
</Component>
I want it so that when it uninstalls that it does not delete the key but just sets it to 0 as I am unsure what the behaviour of the taskmanager would be if the key was deleted.
I'm also assuming Action="createAndRemoveOnUninstall" should be something else?
"Action" has been deprecated and instead you should be using "ForceCreateOnInstall" and/or "ForceDeleteOnUninstall" instead.
You can also use "NeverOverwrite" on the component to make sure that the registry value isn't removed.
To set the value you can use a custom action that is scheduled to run only during the uninstall. Use NOT UPGRADINGPRODUCTCODE as the conditional for your custom action to ensure it only executes during uninstall.
For the custom action under Product AND Package add
<InstallExecuteSequence>
<Custom Action="YourCustomAction" After="InstallInitialize"><![CDATA[(NOT UPGRADINGPRODUCTCODE)]]></Custom>
</InstallExecuteSequence>

different shortcut behavior during unattended installation

I am trying to create a Start Menu shortcut. This is the code I'm using:
<Fragment>
<SetProperty Id="MIFOLDER" Value="[INSTALLFOLDER]\MI" Before="CostFinalize"></SetProperty>
<!-- Start menu -->
<Icon Id="iconCMD" SourceFile="$(var.SharedComponents.ProjectDir)Images\Icons\cmd.ico" />
<DirectoryRef Id="STARTMENUFOLDER">
<Component Id="cmp211060161C737F50377C120FF39D7623" Guid="{E7B9FB15-4A1D-4E3E-BCDE-EB2E5638C452}" Win64="yes">
<Shortcut Id="shrtct211060161C737F50377C120FF39D7623" Name="Management Interface (MI)"
Target="[System64Folder]\cmd.exe" Icon="iconCMD" Arguments='/k "title Managment Command Line Interface (MI)"' WorkingDirectory="MIFOLDER" />
<RegistryValue Root="HKCU" Key="Software\$(var.Manufacturer)\VB\Installer\$(var.ProductName)\MI"
Name="MI" Type="string" Value="$(var.VersionNumber)" KeyPath="yes" />
<RemoveFolder Id="rem211060161C737F50377C120FF39D7623" On="uninstall"/>
</Component>
</DirectoryRef>
</Fragment>
I want this shortcut to run Command Line Interface and start it in installation folder.
When running the setup normally, it indeed works fine and all well.
When I'm installing with /q (unattended), and after installation I click the shortcut, and it leads to Windows\system32 directory and not working directory. When I look at shortcut properties, I see that it set to start at \MI as SetProperty action doesn't take place.
Any help and ideas why?
InstallUISequence will be skipped in silent installation. Use Sequenceattribute to run the SetProperty action as per your requirement(both or first).

writing registry in wix - problem illustrated with sample wxs file

I am trying to write to registry using Wix.
it is failing showing the error
"The error code is 2727"
to run this sample follow the below steps.
you need a text file in c:\testinstall.txt
it installs the file testinstall.txt in
C:\Program Files\testinstall
candle sample.wxs
light sample.wixobj
sample.msi will be created
when i add this entry in the script
it is failing.
all i need is to have a script which will create a key and write some value into the
registry.
sample.wxs code
2
<Registry Id="TestKey"
Root="HKLM"
Key="SOFTWARE\testCorp"
Action="createKeyAndRemoveKeyOnUninstall">
<Registry Id="TestValue"
Name="TestValue"
Action="write"
Value="123"
Type="string" />
</Registry>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="Feature" Level="1">
<ComponentRef Id="component0" />
<ComponentRef Id="ID0EAAA" />
</Feature>
Are you using WiX v2? Instead of creating the registry value with two Registry entries, just combine it all into one line.
<Registry Id="TestKey" Root="HKLM" Key="SOFTWARE\testCorp" Name="TestValue" Value="123" Type="string" Action="write" />
That's usually a lot easier. If you really want to nest them then I recommend leaving the Registry/#Action attribute off of the parent registry key so it doesn't actually end up in the MSI. Just organizes the child elements.
Note the syntax is a bit different in WiX v3.