2

I am working on a console application that I want to run in the background of machines from the moment they boot to shutdown. Now I know that it would be optimum to create a Windows Service, but in this case I need to be able to intetact with certificate stores and I do not believe that a local service account certificate store will do.

I am looking at System.Timers for keeping the application running rather than bludgening in to death with an infinite while statement, is this a logical way to handle this or is there a better way in which to keep the application open? The application will be checking into a SQL database frequently to see if there is any work to do.

DanO
  • 67
  • 5

4 Answers4

3

You can run Windows Services under any user with appropriate privileges. You are not required to run it under Local Service account.

Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
1

Alternatively, you could use a tray icon to keep you application running, see here for a sample.

Although, you can run the application as a windows service it requires additional installation overhead. Also = as far as I understand the OP - the application should close when the user logs out, this does not hold true for windows services. So you will have close it explicitly when this behaviour is required.

AxelEckenberger
  • 16,628
  • 3
  • 48
  • 70
0

You could create a windows service and impersonate the user to access the necessary certificate stores. See this question: SO Question

Community
  • 1
  • 1
Bryan Rowe
  • 9,185
  • 4
  • 26
  • 34
0

Now I know that it would be optimum to create a Windows Service, but in this case I need to be able to intetact with certificate stores and I do not believe that a local service account certificate store will do.

In Windows XP:

Start->Settings->Control Panel->Administrative Tools->Services

Right click on your service->Properties->Log On tab->This Account->Specify account to run as

It's something similar for Windows Vista and Windows 7 but I'm on an XP machine right now.

I am looking at System.Timers for keeping the application running rather than bludgening in to death with an infinite while statement, is this a logical way to handle this or is there a better way in which to keep the application open?

A System.Timers is fine for periodically doing something. Again, you can implement this in a Windows service though.

jason
  • 236,483
  • 35
  • 423
  • 525