We help IT Professionals succeed at work.
Get Started

Setting CurrentUser\Run in msi setup custom action fails with no message

715 Views
Last Modified: 2012-05-12
I have a .Net 4 msi setup project that runs a VB program as a custom action. This program attempts to set a string value in the the registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Run. I get no error yet the key value is not set. I have attached a code snippet. The code works when I test it from visual studio, but not when it is in the msi routine. I also elevated the priveleges. Same error. How do I get this to work?
Try
            regStartPgmKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
            If regStartPgmKey Is Nothing Then
                MessageBox.Show("Error accessing Startup program registry key." & vbCrLf & "Process will continue", _
                    "BDS Intstall/Uninstall error", _
                    MessageBoxButtons.OK, _
                    MessageBoxIcon.Error)
            End If
            regStartPgmKey.SetValue(PgmName, Path.Combine(TargetDir, PgmName))
            regStartPgmKey.Close()
            MessageBox.Show("After Set " & PgmName)
        Catch ex As Exception
            MessageBox.Show("Error accessing Startup program registry key:" & ex.Message & vbCrLf & "Process will continue", _
                "BDS Intstall/Uninstall error", _
                MessageBoxButtons.OK, _
                MessageBoxIcon.Error)
        End Try

Open in new window

Comment
Watch Question
Tech Lead (Windows), Endpoint Device Management Services
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 8 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE