-2

I want to automatically start a hotspot on my laptop (windows 8).
This is done by the cmd command "netsh wlan start hostednetwork".
I have to log in on my WiFi before using it, so i want to start my hotspot after i have opened the browser. So i want to call a JavaScript file as start page, that executes the command (start page is called after the WiFi is activated). Is there a way to execute the shell command via JavaScript? or do you have better ideas to achieve the same?

Nafta
  • 71
  • 1
  • 7
  • 1
    This is not possible with javascript. It would be extremely dangerous if javascript was able to execute cmd commands. – Jerodev Oct 22 '14 at 08:46

1 Answers1

1

JavaScript has no access to call commands like that.
Imagine the security risks if that were possible. *shudder*

You could, however, make an ajax call to a local server, and use a server-side language to execute the command.

Cerbrus
  • 70,800
  • 18
  • 132
  • 147
  • Which language would you recommend? Does this work with php and xampp? – Nafta Oct 22 '14 at 08:57
  • That could work. `php` has [`exec`](http://php.net/manual/en/function.exec.php), for example. Just keep in mind that this is far from safe. Don't allow user input to appear in the `exec`. Or better yet, make the function available only from, for example, your PC. – Cerbrus Oct 22 '14 at 08:59
  • i only want to call it from my own pc to start the hotspot, no other usage, i just want to act out my laziness :P thanks for the fast answer :) – Nafta Oct 22 '14 at 09:01
  • Hm, then another option could be a shortcut to a `.bat` file. You can assign keyboard shortcuts to shortcuts. ;-) – Cerbrus Oct 22 '14 at 09:02