I'm working on a fun little beginner's project. I am trying to build a face recognition program using node js for my laptop to run upon login. I want it to take a picture whenever someone logs into my laptop and to check the face then I want it to shut down if it's not me. I will use the face-recognition npm package for the recognition part but I can't figure out how to shutdown my computer using javascript. I tried using the child_process package but it doesn't work when I type in exec('shutdown') for some reason. any ideas? (keep in mind I am a newbie so explain it to me like a 5-year-old).
-
1Could you edit the question and post what code you have so far? And what operating system are you running this on?kimbo– kimbo2020-04-23 00:15:44 +00:00Commented Apr 23, 2020 at 0:15
-
4What OS is this?GetSet– GetSet2020-04-23 00:28:44 +00:00Commented Apr 23, 2020 at 0:28
Add a comment
|
1 Answer
As far as I know there is no native way for Node to shut down a computer. However, Node does have the ability to execute shell commands and these shell commands can be used to shut down a computer.
For example,
On Linux shutdown -h now will shut down the computer now.
Using childprocess you can execute the shell command for shutdown.
See here for an example of how these work.