5

I have WPF Application. I want to give ability for user by checkbox to put App (exe file) to the windows Startup. How Can I do this programmaticaly in C#?

Polaris
  • 3,643
  • 10
  • 50
  • 61

3 Answers3

6

You will need to add the application to the HKCU\Software\Microsoft\Windows\CurrentVersion\Run key in registry. See this for an example in C#: Managing Start-up

Giorgi
  • 30,270
  • 13
  • 89
  • 125
1

You can add your program to the registry, the folder would be [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]. You do this by adding a new string value, eg. "Notepad"="c:\windows\notepad.exe".

A short guide

Femaref
  • 60,705
  • 7
  • 138
  • 176
1

I'm adding it for reference only as question already answered.

These are all possible locations to register application in startup.

SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunServicesOnce
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunServices
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\Setup
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunEx
SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run
Yash
  • 6,644
  • 4
  • 36
  • 26