0

I wrote a windows service in C# .NET 3.5. It starts up automatically and runs as Local System User (no log in required).

If i run a Shutdown-Batch-File (shutdown -s -t 30) with my service by calling Process.Start(), nothing happens until i log in to windows. So it waits for logging in and then starts the batch.

Is it possible to run this batch in logged off state?

Greetings

agf
  • 171,228
  • 44
  • 289
  • 238
MariusK
  • 537
  • 5
  • 20

2 Answers2

0

There is a property for each service application called Allow Interact With Desktop that should be set True for your service to be able to run Shutdown-Batch-File.

Take a look at these links:

Interact With Desktop when Installing Windows Service

Allow service to interact with desktop in C#

fardjad
  • 20,031
  • 6
  • 53
  • 68
0

Have you checked to make sure this is not a permission issue? Ie does it work if the service is running as an administrator?

You might also want to try the alternative methods of shutting down mentioned in this question how-to-shutdown-the-computer-from-c#.

Community
  • 1
  • 1
sgmoore
  • 15,694
  • 5
  • 43
  • 67
  • yes i have checked it. (by using administrator) maybe a batch cannot be started while logged off? it seems that the batch will only be queued and waits for logging in. i will try your alternative method of shutting down via direct shutdown.exe-call, thanks. any1 else got an idea?? – MariusK May 12 '11 at 11:58