1

newbie here, so please forgive me obvious mistakes. To the point:

I have set of 12 computers, each one is running Windows 10. My goal is to make php script which will allow to turn on/off each machine. I've already figured out part with turning via WOL, but I am stuck on turning off.

I do have shell command which works perfectly when typed to cmd.exe directly, so I tried to put it in exec() and shell_exec().

Code was: <?php exec('shutdown /m \\computer_name /s /f'); ?> and it did nothing.

Is there any way to make this work? What kind of solution can I use? I tried executing .bat files, but no success, I think my syntax was wrong. Can you show me the right direction?

Server is another Windows 10 machine with WAMP installed.

tomatow
  • 43
  • 4
  • The backslash needs escaping in PHP single quoted strings too. Your exec call would only yield one before the computer name. Also print the result of the exec() call, perhaps with [`2>&1` stderr](http://stackoverflow.com/questions/1420965/redirect-stdout-and-stderr-to-a-single-file) redirected (to find out if it's an authorization issue). – mario Aug 28 '15 at 21:20
  • Building on what mario said, instead of using `/` use `-` ... `-m \\computer_name` – ElefantPhace Aug 28 '15 at 21:24
  • I've changed the code to: ` log.txt 2>&1"); ?>` Nothing happened on remote host, but in log file is info: Access Denied (5). I had this situation earlier when command was executed via windows cmd.exe, but managed to fix that by changing privileges on remote host. What's the solution here? Can I somehow add privileges to php script? – tomatow Aug 28 '15 at 21:43
  • This helped: http://stackoverflow.com/a/21119439/5278480 Now it works! – tomatow Aug 28 '15 at 22:03

0 Answers0