5

I have a simple C# application that allows users to specify that it should be (or should not be) started with Windows; it does so by setting (or deleting) a registry key (namely, ...\Software\Microsoft\CurrentVersion\Run\MyApplicationHere).

I am using a VS setup project to create the installer for this program. I don't want the installer to create this key; it should only be created when the user selects the option from within the program.

Here is the issue: I would like the uninstaller to delete this key if it exists, preferably without resorting to any sort of hackery; if there is a simple "built-in" solution I would love to hear it. Thanks!

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Zach Snow
  • 1,014
  • 8
  • 16

3 Answers3

8

just right Click on Setup then Select View -> Registry, you can add a registry key to the list. The key has properties (right click -> Properties) AlwaysCreate,DeleteAtUninstall and Transitive keep AlwaysCreate to false, and DeleteAtUninstall to true and Transitive to true as well adn its Done..

Kiran Solkar
  • 1,204
  • 4
  • 16
  • 29
  • 1
    This does not work with `HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run` When I set `DeleteAtUninstall` on the `Run` key to true, it deletes ALL values in that key (also values created by other applications). – ndreisg Dec 21 '18 at 09:50
2

The Registry table is designed for this:
http://msdn.microsoft.com/en-us/library/aa371168(VS.85).aspx

See especially under the description of "Name":
If the Value column is Null, then the strings shown in the following table in the Name column have special significance.

- The key is to be deleted, if present, with all of its values and subkeys, when the component is uninstalled.

William Leara
  • 10,595
  • 4
  • 36
  • 58
0

Try creating a custom uninstall action to remove the key. Not very "built in", but it's only a couple of lines of code.

Hannes Nel
  • 532
  • 2
  • 15
  • This works fine, and if no more "built-in" answer is in evidence it's good enough for me. Thanks. – Zach Snow Nov 26 '09 at 03:33
  • 1
    If you right click on your install project, View -> Registry, you can add a registry key to the list. The key has properties (right click -> Properties) AlwaysCreate, and DeleteAtUninstall, which should perform what you need, based on the stuff in the other post about the Registry table. Don't add a value to the key, set AlwaysCreate to false, and DeleteAtUninstall to true. – Hannes Nel Dec 02 '09 at 02:23