2

Trying to run a command in NodeJS that simply puts my computer to sleep, but the command ended up hibernating it?

exec("rundll32.exe powrprof.dll, SetSuspendState Sleep");

By sleep I mean, when I wake it up, it instantly comes back to the Windows User Login screen, however when I used the command above, when I woke the computer back up, it came back to the BIOS screen. My session was still saved but I want it to instantly go to the Windows User Login screen, so I think it actually hibernated my computer.

What's the correct command to get it to sleep properly?

Joe Bid
  • 121

2 Answers2

0

Psshutdown is the solution:

exec("psshutdown.exe -d -t 0", (err, stdout, stderr) => {
    console.log('stdout is:' + stdout)
    console.log('stderr is:' + stderr)
    console.log('error is:' + err)
  }).on('exit', code => console.log('final exit code is', code))
Joe Bid
  • 121
0

hibernate the local computer. as below steps:

  • step1.

    switch hibernate command: powercfg.exe /H on

  • step2.

    shutdown.exe /h

vingo
  • 11