Start when Windows Starts

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

I want to add a checkbox preference to my windows app :

Start When Windows Starts

How can I ensure that the program is indeed started when windows starts when
the preference is set (rather than just rely on the user adding it to his
Startup program group).
 
That works, but if I turn off the setting how can I delete such a key in the
registry? The command:

Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run").DeleteValue("myKey");

throws an exception about permissions.
 
You could always put a shortcut in the startup folder (C:\Documents and
Settings\All Users\Start Menu\Programs\Startup) if you didn't want to play
around with the registry.
 
You need to open it as writeable:
Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run",
true).DeleteValue("myKey");

/claes
 
Doh! Now I feel silly.

Cheers mate.

Claes Bergefall said:
You need to open it as writeable:
Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run",
true).DeleteValue("myKey");

/claes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top