Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a program at startup

Tags:

c#

wpf

startup

I am currently working on a c# wpf project. I have added code to the program so that it creates a registry key to start the program automatically at user logon and have also written the program so that it can minimise to the system tray.

When the user launches the program themselves manually I obviously want the program to appear in the middle of the screen like normal but when the program launches automatically at startup I want it to load up minimised.

Is there a way to determine if the program was launched by the user or launched at startup so that I can make it load minimised instead of appearing on the screen at startup.

like image 233
Boardy Avatar asked Sep 03 '11 23:09

Boardy


People also ask

What does program do in Startup?

A startup program is a program or application that runs automatically after the system has booted up. Startup programs are usually services that run in the background. Services in Windows are analogous to the daemons in Unix and Unix-like operating systems.

Can I disable program program in Startup?

Navigate to the Task Manager. If necessary, click More details to see all of the tabs; select the Startup tab. Select the item not to launch at startup, and click Disable.


1 Answers

The easiest way would be to register your registry keys with a command line argument, so that when the program starts up automatically you can simply check the args in your main method.

As long as the user doesn't start it from the command line with that argument, you will be able to determine whether the program was auto-started or the icon was clicked.

like image 50
Chris Shain Avatar answered Sep 25 '22 05:09

Chris Shain