0

I have a Windows Forms application needs to update registry values. When I debug the application the values are being saved properly. But when I launch the application after the completion of installer (Visual Studio Setup Project - .vdproj), the application launches properly but it is not saving the registry values properly.

I am not getting any errors but can't seem to find the entries at location.

The values are being saved correctly if I double-click the .exe.

Is it because the installer launches the application as "System" user?

How do I solve this?

Libin TK
  • 1,477
  • 2
  • 25
  • 46
  • Your installer asks for UAC elevation, and gets it, which make a program you start from the installer run elevated as well. That generally makes a pretty big difference when you poke around in the registry. Albeit that it is pretty unclear why you'd have a problem when you run elevated, you should fix that. And not hide the code that does that. There is no simple way to start a program un-elevated so just don't do it. – Hans Passant Nov 11 '17 at 12:47
  • You should say which registry entries your code is trying to update, but if they are HKCU entries, for example, you are going to see differences running with the system account. It is also unclear why you need a program to create registry entries when the setup will do this for you and it will just work. – PhilDW Nov 11 '17 at 17:04
  • @PhilDW I understand mine was an incorrect approach and was able to have the entries created by the setup itself. – Libin TK Nov 12 '17 at 10:16
  • Copied my comment to an answer to provide some closure. – PhilDW Nov 14 '17 at 19:29

1 Answers1

1

You should say which registry entries your code is trying to update, but if they are HKCU entries, for example, you are going to see differences running with the system account.

It is also unclear why you need a program to create registry entries when the setup will do this for you and it will just work. In Visual Studio setup projects that's in the Registry view. Many of the values you may want to store in the registry might be available as standard Windows Installer properties, and store them using the square bracket syntax, such as [TARGETDIR].

PhilDW
  • 20,260
  • 1
  • 18
  • 28