views:

505

answers:

3

How do I startup a computer from C# code at a given time?

This should be done locally from the computer that is to startup, but other alternatives can be interesting.

Are there any prerequisites to get this to work? Like the computer has to just be in sleep mode, not shut down?

+1  A: 

You could do this by "Wake On Lan" if the computer is in a network and the startup-tool is running on a central system (i.e. on a domain controller). It's imho not possible from only one computer if it's really shut down.

Scoregraphic
+1  A: 

Start it on a time controlled by a program on the same PC is not possible to my knowledge.

Remote Startup is possible, i.e. by using Wake-on-Lan, other possibilities include networked powersupplies which allow you to toggle power remotely, you just have to configure the PC to boot on power, usually in the BIOS.

dbemerlin
+4  A: 

you can do this by scheduling a task, don't think you can have a program running which will wake the computer at a specified time. The computer must be sleeping for it to be woken, not off.

you best bet is to write a command line app and schedule this to be kicked off using the scheduler.

Your other option is wake on lan and have a program on another machine send a magic packet to the machine you want to wake up.

I'm not sure if there are any standard libraries that allow you to create scheduled tasks in .net but this code project project seems to try and do it.

Sam Holder
+1 for mentioning the scheduled task (which has a "wake computer" option), that was probably the closest answer to the OP's question.
slugster
How about providing the command to set in the Scheduled Task to make this work?
Seb Nilsson