5

How do I get a Visual Studio Setup Project to:

  • create a registry key only if it doesn't exist
  • not remove the key on uninstall
competent_tech
  • 44,465
  • 11
  • 90
  • 113
DaveO
  • 1,909
  • 4
  • 33
  • 63
  • 2
    This is the kind of stuff that makes Windows users detest the registry :) – BoltClock Nov 26 '11 at 11:34
  • Are you using a third-party installer? – Otiel Nov 26 '11 at 12:24
  • 1
    @BoltClock: Sadly, we have had customers ask us explicitly to leave some of the registry settings intact so they don't have to remember everything they entered the last time they installed the app. – competent_tech Nov 26 '11 at 20:45
  • 1
    What I am trying to do is to leave a mark on the pc which says the software has been installed. This is so we can expire a trial installation. Otherwise the user can uninstall and then reinstall the app and the trial restarts.. not perfect .. is there a better way? – DaveO Nov 26 '11 at 22:14
  • 1
    Little late to the fray, but here's how to not create a value if it already exists: http://stackoverflow.com/questions/7392962/visual-studio-2010-update-registry-in-setup-application – paul Jan 10 '13 at 16:34

1 Answers1

5

Right-click on the Registry key in the setup project and select Properties.

1) To only create the registry key if it doesn't exist, ensure AlwaysCreate is False.

2) To not remove the key on uninstall, ensure DeleteAtUninstall is False.

competent_tech
  • 44,465
  • 11
  • 90
  • 113
  • 4
    Ahhh, I was looking at the individual registry name/value entry not the key. I'd prefer these options on the name/value properties but the key might suffice. On second look though even if DeleteAtUninstall is False the key will still be deleted if it was created during installation. – DaveO Nov 26 '11 at 22:07
  • 3
    Did anyone find a solution for this. Dave has mentioned that the values in the key still get deleted even after setting DeleteAtUninstall=false. I have the same issue too, – StackThis Oct 09 '12 at 16:05
  • If there is a hierarchy of the `Keys` and the topmost `Key` is set as DeleteAtUninstall=true it could override the children's DeleteAtUninstall=false setting. – mandarin Apr 29 '15 at 14:16