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
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. – Community Feb 02 '23 at 06:33
  • Please share the actual code you used to solve your problem so it can be a useful reference for others who come along with the same problem. – jfriend00 Feb 02 '23 at 06:46
0

hibernate the local computer. as below steps:

  • step1.

    switch hibernate command: powercfg.exe /H on

  • step2.

    shutdown.exe /h

vingo
  • 11
  • But that will hibernate it. – Rohit Gupta Feb 08 '23 at 07:51
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Feb 08 '23 at 07:51