views:

421

answers:

2

Hello there. 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!

A: 

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
This works fine, and if no more "built-in" answer is in evidence it's good enough for me. Thanks.
Zach Snow
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
A: 

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
This looks like what I need; I'll give it a try.
Zach Snow
If you specify to delete from HKCU, won't this only delete from HKCU for the current user, not for all users?
Rory