-1

I have app who is need to working when Windows OS is starting. Is it possible to make my WPF application to running when Windows OS is running like Skype. I using .NET Framework 4.5.2.

For my application info is need only make QR Code and print with label printer. Is not really important to have some user interface.

B.K.
  • 9,982
  • 10
  • 73
  • 105
evelikov92
  • 755
  • 3
  • 8
  • 30

3 Answers3

6

The most common ways are:

  1. Make it a service. You are mentioning WPF but then you are mentioning you don't need a user interface. Services by default can't have user interfaces, if you need one, you'll need to make a helper application: the most common way of handling this is using the same executable with a command line argument (one to start as service, without UI, and one to start as the helper app which communicates with the service).
  2. Make it a task on the task scheduler, to make it run on boot use a trigger (there's a On startup trigger). You can use the command line:

    SCHTASKS /Create /TN YourTaskName /TR C:\Path\To\Application.exe /MO ONSTART
    

    (you can use ONLOGON instead of ONSTART if that's better for you)

  3. Add your application to the Run list on the registry, in, for example, [HKCUor HKLM]\Software\Microsoft\Windows\CurrentVersion\Run

There are others (start menu, etc.), but these three are the most common

Jcl
  • 27,696
  • 5
  • 61
  • 92
0

Jcl mentioned the service options. There's also the good ol' Startup folder option:

%programdata%\Microsoft\Windows\Start Menu\Programs\Startup <-- Common %appdata%\Microsoft\Windows\Start Menu\Programs\Startup <-- Current User

Place a shortcut there, and your program will start when Windows starts and user logs in. If you place it into the Startup folder for all users (common), you'll probably need administrative permissions.

B.K.
  • 9,982
  • 10
  • 73
  • 105
  • I wouldn't rely a lot on the startup folder... while it's still there in Windows 10, it's well hidden on the roaming profile or program data folders, and not at all directly accesible. I wouldn't rely on it being there on future versions of windows (that said: yeah!, it's still an option today) – Jcl Mar 08 '16 at 09:12
  • @Jcl Yeah, it's just an option. I've used it a lot when I needed a quick way to auto-start a program, but didn't want to deal with services or task scheduler because of lack of administrative permissions for deployment site or other reasons. – B.K. Mar 08 '16 at 09:13
0

Do the following:

  1. Click Start button
  2. Click Control Panel
  3. Click System and Maintenance
  4. Click Administrative Tools
  5. Select Task Scheduler

Or just type "Task Scheduler" in the start menu.

Here you can create a new task. As Trigger you would choose "On Start" or something similar.

As action you would pick the executable file for your WPF application.

チーズパン
  • 2,752
  • 8
  • 42
  • 63