Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to find and change a registry value in WIX using XSL

Posted on 2014-08-26
8
Medium Priority
?
580 Views
Last Modified: 2014-08-28
This is the xml...

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment><DirectoryRef Id="InstallDirx64" /></Fragment>
    <Fragment><ComponentGroup Id="LouComponentx64"><Component Directory="InstallDirx64" Id="cmp123321" Guid="{0B7441C0-A876-41BA-87C9-077CED712FAA}" Win64="yes">
<Condition>VersionNT64</Condition>
                <File KeyPath="yes" Source="$(var.louDLL.TargetDir)\louDLL.dll" Id="fil123321">
                    <TypeLib Id="{90BB27B2-9EB2-4B8D-930F-58B7F74D686E}" Description="louDLLLib" HelpDirectory="InstallDirx64" Language="0" MajorVersion="1" MinorVersion="0"><Class Id="{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}" Context="InprocServer32" Description="lou Class" ThreadingModel="apartment" Version="1.0" Programmable="yes" Control="yes"><ProgId Id="lou.1" Description="lou Class"><ProgId Id="lou" Description="lou Class" /></ProgId></Class><Interface Id="{51154861-52EE-40AA-96B0-5DF53324E7F8}" Name="IShareImage" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" /><Interface Id="{8FE4941F-EE44-4389-A083-344B392FE2FF}" Name="Ilou" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" /></TypeLib>
                </File>
                <RegistryValue Root="HKCR" Key="*\ShellEx\ContextMenuHandlers\lou" Value="{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}" Type="string" Action="write" />
                <RegistryValue Root="HKCR" Key="CLSID\{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}\MiscStatus\1" Value="132497" Type="string" Action="write" />
                <RegistryValue Root="HKCR" Key="CLSID\{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}\MiscStatus" Value="0" Type="string" Action="write" />
                <RegistryValue Root="HKCR" Key="CLSID\{246FDA8F-F37B-4CD7-B580-D2A0931B16F6}\ToolboxBitmap32" Value="[#fil4E063919C21DFFABD05CADC857B9D549], 106" Type="string" Action="write" />
                <RegistryValue Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\Explorer" Name="GlobalAssocChangedCounter" Value="1" Type="integer" Action="write" />
            </Component></ComponentGroup></Fragment>
</Wix>

Open in new window


I have already modified a number of values using xsl, here is part of that...

 
<xsl:template match="wix:Component">
    <xsl:copy>
      <xsl:apply-templates select="@*" />
        <!-- Adding the Win64-attribute as we have a x64 application -->
        <xsl:attribute name="Id">
          <xsl:text>cmp123321</xsl:text>
        </xsl:attribute>		
        <xsl:attribute name="Guid">
          <xsl:text>{0B7441C0-A666-41BA-87C9-098CED712FAA}</xsl:text>
        </xsl:attribute>		
		<xsl:attribute name="Win64">yes</xsl:attribute>
		<xsl:text>&#xa;</xsl:text>
		<xsl:element name="Condition">VersionNT64</xsl:element>
        <!-- Now take the rest of the inner tag -->
        <xsl:apply-templates select="node()" />
    </xsl:copy>
  </xsl:template>
   
   <xsl:template match="wix:File">
   <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:attribute name="Id">
         <xsl:text>fil123321</xsl:text>
      </xsl:attribute>
      <xsl:apply-templates/>
   </xsl:copy>
   </xsl:template>
   
   <xsl:template match="wix:RegistryValue">
   <xsl:copy>
 </xsl:copy>
   </xsl:template>

Open in new window


What I want to do now is change "Value="[#fil4E063919C21DFFABD05CADC857B9D549]" (the fourth RegistryValue down), to Value="[#filfil123321]" , to agree with the file id of above (which I will provide in the replace statement)

I have started the xsl:template match, but do not know how to search\get to, that particular value, and replace it.

Please give me the exact code, please do not point me to something that might help.  I have done searches, and have not found what I am looking for.
0
Comment
Question by:eelou
  • 5
  • 2
7 Comments
 

Author Comment

by:eelou
ID: 40286367
Some additional information.  The xml is harvested using WIX heat, every time the installer is build.  So, the number of registryvalue records could change (if the product developer made changes to the dll).  So, counting down to the fourth record is not an option.  Actually, it would be preferable to search for "[#fil", and change the entire value of that "value=", value.
0
 
LVL 36

Accepted Solution

by:
mccarl earned 1500 total points
ID: 40286926
Try replacing the last template from what you posted above (the match="wix:RegistryValue" one) to the below...
    <xsl:template match="wix:RegistryValue/@Value[fn:starts-with(., '[#fil')]">
        <xsl:attribute name="Value">[#fil123321]</xsl:attribute>
    </xsl:template>

Open in new window

(Note that this is assuming that somewhere else in your XSL you have a default "copy" template that is already copying everything else)
0
 

Author Comment

by:eelou
ID: 40287802
I am fairly new to XML and XSL, I am missing something here.  
I added the xpath-function...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
    xmlns="http://schemas.microsoft.com/wix/2006/wi"
  exclude-result-prefixes="wix">

Now I get Heat error, "error applying transform...Cannot find a script or an extension object associated with namespace 'http://www.w3.org/2005/xpath-functions'"

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:eelou
ID: 40288129
Could not use that code, removed the xpath-functions, had to do this...

<xsl:template match="wix:RegistryValue[substring(@Value, 1, 5) = '[#fil' ]">
      <xsl:copy>
	    <xsl:apply-templates select="@*"/>
          <xsl:attribute name="Value">[#fil123321]</xsl:attribute>
		<xsl:apply-templates/>
	  </xsl:copy>
    </xsl:template> 
	

Open in new window

0
 
LVL 36

Expert Comment

by:mccarl
ID: 40289392
Now I get Heat error, "error applying transform...Cannot find a script or an extension object associated with namespace 'http://www.w3.org/2005/xpath-functions'
Unfortunately, I don't know anything about Heat in particular so I can't help there, other than to say that some processors MAY let you leave off the fn: prefix on the starts-with function and then you can omit the xmlns:fn declaration.

However, if you are able to use the substring method without qualifying it (which makes me think that you can do the same with starts-with) then you should still be able to do it much like the first post that I gave, ie...
    <xsl:template match="wix:RegistryValue/@Value[substring(., 1, 5) = '[#fil']">
        <xsl:attribute name="Value">[#fil123321]</xsl:attribute>
    </xsl:template>

Open in new window

0
 

Author Comment

by:eelou
ID: 40289969
WIX does not work with 2.0 yet.   That is why your code does not work.
0
 

Author Closing Comment

by:eelou
ID: 40289972
Could not use the code provided.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question