Search code examples
c#.netvisual-studio-setup-proje

How to update Registry Values as "System" user?


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?


Solution

  • 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].