I have web based application which automatically loads on kiosk mode (full-screen) in chromium web browser on client's Computer wich is powered by Windows 7. I want to place a shutdown button on web page, so that user can directly shutdown the computer.
-P.S-
I've full control over client's computer. (installing other software or browser extensions). it is a touch screen POS unit.
As you have control over the target machine, this is completely feasible. One way to do it is by introducing a separate component to perform the shutdown.
Create a console application (using C#, for example) that listens to stdin, that shuts down the machine when it receives the right input. Machine shutdown from C# is not entirely trivial, but Stackoverflow knows how it is done.
Register this application with a proper manifest given the Google Chrome Native Messaging specification.
Call this extension from your webpage (on shutdownButton.click(), for instance) using Message Passing.
The individual steps are a bit too broad to fully detail them in a single answer, but you can always open new questions on them if they give you any trouble.
Because of security reasons this is simply not possible without running something outside of your browser.
If however the page is served from a server and you want to shutdown this server, keep reading:
A solution which would be possible is to run a server in the background, for example node.js.
On your node.js server you could listen for a specific url you are calling, on the trigger of this event you could send a shutdown command to your host. This however opens some security issues, you need to block this call to node from the outside (or not if you want others to be able to shut it down). And your node.js server has to be running with root rights which is also risky.
Take a look at https://github.com/typicode/stop-server maybe you can find something in there that's usefull to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With