No announcement yet.

Can we have certain registry keys added as 'create' only?

  • Filter
  • Time
  • Show
Clear All
new posts

  • wesley
    hmm.. No reply from Daryll. Don't know if anyone else will come accross this problem, but if you do and find yourself needing to update thousands of Add registry Key entries from "Create and Remove on Uninstall" to just "Create" You can open the .msifact file in any text editor and manually do it. Search for xml looking like

    <SetupItem Type="2" ID="RegKey_0034" ComponentID="YOUR.dll">

    Dont use Find and Replace as the elements you need to change (the line "<Actions>2</Actions>") also appear in the Set registry Value commands and tell MSIFactor to Prepend registry keys as opposed to the default.

    I've written a crappy little VB.NET tool to do it.

    To use... Create a new windows forms Application. On your form add 2 buttons (One named 'btnBrowse' and one named 'btnGo') and a text box (named 'txtFile'). In your form code paste the following...

    ************************************************** **********
    Private Sub cmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBrowse.Click
    If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
    txtFile.Text = OpenFileDialog1.FileName
    Exit Sub
    End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    OpenFileDialog1.Filter = "XML files (*.xml)|*.xml|MSI Factory 2.01 Files (*.msifact)|*.msifact|All Files (*.*)|*.*"
    OpenFileDialog1.FilterIndex = 2
    SaveFileDialog1.Filter = OpenFileDialog1.Filter
    SaveFileDialog1.FilterIndex = 2
    End Sub

    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click

    Dim Xele As XElement
    Dim lCountModified As Integer
    Dim lintLevel As Integer = 0
    Dim lstrSave As String

    Xele = XElement.Load(txtFile.Text.ToString)

    lCountModified = ModifyRegElements(Xele)

    Console.WriteLine("Modified " & lCountModified.ToString)

    If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
    lstrSave = SaveFileDialog1.FileName

    Dim xmlws As New XmlWriterSettings
    With xmlws
    .Indent = False
    .OmitXmlDeclaration = True
    .NewLineHandling = NewLineHandling.None
    End With

    Dim xw As XmlWriter

    xw = XmlWriter.Create(lstrSave, xmlws)
    xw = Nothing
    xmlws = Nothing
    MsgBox("File Saved")

    xmlws = Nothing
    End If

    Xele = Nothing

    End Sub

    'recursive routine to modify all elements of type SetupItem
    Public Function ModifyRegElements(ByVal lelement As XElement) As Integer

    Dim lblnFound As Boolean = False
    Dim lcount As Integer

    If lelement.Name.ToString = "Actions" Then
    If lelement.Value.ToString = "2" Then
    'Check parent elemts (SetupItem) Type attribute is a 2
    Dim ltyp As XElement

    ltyp = lelement.Parent

    For Each att In ltyp.Attributes
    If att.Name = "Type" Then
    If att.Value = 2 Then
    lelement.Value = "1"
    lcount = lcount + 1
    End If
    Exit For
    End If
    End If
    ElseIf lelement.Elements.Count > 0 Then
    'Console.WriteLine("level:- " & level.ToString & vbCrLf & "Kids = " & lelement.Elements.Count)
    For Each ele2 In lelement.Elements
    'Console.WriteLine("Modifying Kid:- " & ele2.Name.ToString)
    lcount += ModifyRegElements(ele2)
    End If

    Return lcount
    End Function
    ************************************************** *****
    All it does is replace the <Action>2</Action> tags with <Action>1</Action> in every Add registry Key command. It will then save a copy of your original file. Use at your own risk.

    Leave a comment:

  • wesley
    Any news Daryll

    Hi Daryll, Has anything been done abouit this issue? I assume not as these posts are over a year old. My organisation has just paid for a license for MSI Factory yesterday, on my recommendation. I'm pretty new to creating MSI installs and have been using MSI Factory for around 2 to 3 weeks and have been please at how well it works de-mystifying the WIX etc. But... I'm using the method Keiths123 has outlined, to register dlls / ocxs etc and I guess I didn't pay enough attention but one of my colleagues tested my msi out on his machine. Installed perfectly. After Uninstallation, it's bricked his PC! We've tried all manner of things to get the system operating again to no avail. There really should be some sort of warning when importing registry settings as novice users like myself will fall into this trap!

    Leave a comment:

  • Darryl
    I've submitted your comments to be looked at, thank you.

    REF: 18930

    Leave a comment:

  • Can we have certain registry keys added as 'create' only?

    If I go to System Editors, Registry, Import and then select a DLL it creates the "Add Registry Key" folder with a bunch of new registry keys, all of them with a default of "CreateAndRemoveOnUninstall".

    Can this be changed so it doesn't remove the following keys on uninstall:

    I normally go through and manually change all of these myself as you can really damage a machine if you don't.

    It would also be very useful if these keys were only added once. If you have more than one dll in an install that needs registering, it will create a top level key for each file that is selected from the import function.