How to power-on Windows 10 PC, run task, then shut down again

How to power-on Windows 10 PC, run task, then shut down again

I want my Windows 10 PC to power-on from "off" in the middle of the night, run a CPU intensive task for a few hours, and then power back off in a clean shutdown. What would it take to do this? Windows Task Scheduler has a "Wake Computer" option under Actions. But will this Power-On a PC? I'd prefer not to use sleep or hibernation, because I want the PC to be a a clean shutdown state between runs.

I expect I can configure my motherboard to power on every night on a schedule. Then I suppose I could use Task Scheduler to check the time, and if appropriate, execute a PowerShell script. Is there a better approach?

答案1

If you can have your computer turn itself on, Task Scheduler is certainly the way to run a task and shut down after either as part of the job or task (shutdown /s). Task Scheduler is suited to this.

Because the job may not run to an exact time of execution, better to shut down from the job. Use a batch file or script to run the job and include shutdown /s at the end.

If you cannot get the computer to start automatically, consider using Wake on LAN to see if that might work.

There are small boxes (numerous) that can be adapted to a desktop computer to start it as well.

答案2

Wake timers setup in Task Scheduler work well when waking from sleep. Powershell scripts can also be run from Task Scheduler, but they may not run if the execution policy isn't set to remote signed. Depending on the complexity of the script you could also use a batch script.

Power-On timers in BIOS can be scheduled to perform cold starts. If you're trying to scale this across multiple computers Wake-On LAN can also be setup in BIOS. This way you can start the computer remotely. On the remote computer you'll also have to enable Wake On Magic Packet under the advanced tab in the network adapter. This can be done with the CMD command wolcmd [target MAC addres] [target IP address] [subnet mask] [port (most likely 7)]

答案3

Some computers (e.g. HP business series) have a BIOS option to turn on the computer at specified times. Maybe for your PC this option is available as well, either directly or with a BIOS/UEFI update.

Another option, as suggested by John, would be Wake on LAN (WoL). For that, you'd need another device in the network which can send the signal. Some routers support this out of the box.

答案4

First of all, I would not trust any process to do this with high reliability. Even if the process itself was flawless, lots of things can go wrong when physically powering up a PC.

Most server class hardware have a dedicated management interface that allows things like remote KVM and remote power up or down. Usually in the form of a dedicated low-power chip with a dedicated network interface. For example, most supermicro products ship with a "BMC IPMI" (Baseboard Management Controller Intelligent Platform Management Interface) that allows you to soft power down, hard power down, and power up the computer it is embedded in. And remote API access.

You could then write a script to connect to the IPMI interface, and power the system up. From there Windows Task Scheduler could handle launching the task, then soft power down. After a certain amount of time passes, your script could then force a soft power down or a hard power down from the IPMI interface in case the windows script failed to power down.

That being said, I am struggling to come up with a problem where physically powering up and down a system every day is the best solution.

相关内容