+ 2

How to shut down a system using JavaScript

Is it possible to shutdown a device or system using JavaScript command? If possible, how can it be done? Thanks.

29th Sep 2020, 5:05 PM
Nathaniel Temitope Ogunjobi
Nathaniel Temitope Ogunjobi - avatar
5 Antworten
+ 7
It is not possible to do it with browser JS. But with NodeJS you can execute the corresponding shell commands. In windows, it will be like this const { exec } = require('child_process'); exec('shutdown /s');
29th Sep 2020, 6:48 PM
Ore
Ore - avatar
+ 2
No you can't shutdown system with JavaScript directly because it runs on browser and browsers don't have access to anything that is not inside the browser. However, nodejs can do that because it runs on your system directly. So what @Ore mentioned.
29th Sep 2020, 7:05 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
Thanks guys
29th Sep 2020, 7:42 PM
Nathaniel Temitope Ogunjobi
Nathaniel Temitope Ogunjobi - avatar
0
Some one help me with the code for shutting down a Linux system in JavaScript
25th Jul 2022, 8:32 AM
Prince Aubrey Nuwagaba
Prince Aubrey Nuwagaba - avatar