Santosh Kokatnur
Santosh Kokatnur

Reputation: 364

How to start WinForms application after user logs in to desktop?

Here I have created one windows application (Scheduler) it is having some listbox,checkbox, buttons. I just need to run that application when windows log on particular set of time it should run.

This is my Sample Win App

Upvotes: 1

Views: 489

Answers (1)

Reza Aghaei
Reza Aghaei

Reputation: 125197

If you want to put your application in start up and check user selected date and time and show the form to user at that times:

  • Change your application main form to be hidden. (for example this.Hide(), or this.Visible= false in Load event)
  • Save the user selected date and time in a setting file.
  • create a timer that checks current date and time, and if this is the time to run, show the main form.
  • Then put your application at start up.

Put application in startup

Option 1:

If you need put your application at start up programmatically, you can do it using this registry key. Write a C# code to open the key:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\

And then create string value and set a name for it and in value, put address of .exe of your appplication.

Option 2:

If you want to put your application in start up manually, you can simply put your application in startup using Addministrative Tools -> Task Scheduler -> Create Basic Task and then in wizard, In Task Trigger Page, Select When I logon.

Key Points:

  • If you use a .Setting file in your project, the settings will be saved per user and you should not be worry about settings of different users.

  • If you put program at startup using registry or task scheduler, the program runs after user logon.

  • Registry trick can be applied during installation or at first run of application.

Upvotes: 1

Related Questions