Search code examples
vb.netinstallationregistry

How can write values in Registry while installing VB.net application?


I want to make use of registry to store installation date.

This would allow me to check application expiry on each run, so when I install my application on any PC the registry subkey will be created and store current date as installation date.

I am using Visual Studio Installer Set up and Deployment.

If you have any other suggestion to achieve this, please share.


Solution

  • As a general answer, create a registry item and put the appropriate Windows Installer property there, in this case [Date] in square brackets, case-sensitive, just like you'd put [TARGETDIR] to record the installation folder. This avoids code.

    However it is a bad idea, as the comments point out. Apart from the fact that it can be defeated, the poor person that installs it then can't use it for a week is in trouble. You should start the clock on first run of the app. That's fair and accurate.

    Otherwise, give each user something unique, maybe a license key, and have the app call into your company's web service on first run, saying "this key started now", then you can check every time the app runs and say no after the timer has expired, then you're using your company's clock, not the user's.