'How to restart computer using js [closed]

is it possible to restart computer using nodejs? I've searched whole day but I still have no idea how to do it or is it possible. Maybe I can make restart.bat and run it in my js program? I'm grateful for any piece of code, idea, recommendation or anything. Thank you!



Solution 1:[1]

As far as I am aware, there is no node feature to shutdown or restart the computer. However, node is able to run shell commands.

shutdown -h now is the command on linux.

You would use childprocess (here) to shut it down on Windows.

What is the reason you are looking to shut it down? There may be more effective methods depending on situation and reason.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alien_jedi