0
votes

I am trying to execute a script file (Batch or Python) in PHP (local WAMP server) that will open a program on my computer and send a keyboard shortcut to put the the program in fullscreen mode. I have this script already made using AutoHotKey (.ahk scripts).

I tried using these PHP commands to open a Batch file that runs the .ahk script:

system("cmd /c C:\wamp64\www\test.bat");
exec("test.bat");
exec("cmd.exe /c test.bat");

But all of these seem to just run the script on the webserver and not on my Windows computer so the .ahk file is never executed. I also tried directly executing .ahk file but I couldn't get that working either.

Does anyone know of a way I can use PHP(or another web language) to execute this script on my computer?

1
Thanks for that suggestion, I tried changing the log on settings for "wampapache64" to my personal account and I also tried allowing desktop interactions however neither worked (after service restart).pclever1

1 Answers

0
votes

You have to specify absolute path for the batch file, as the CLI SAPI has nothing to do with WAMP's document root.

You have tried to pass full path in the first command. But the sequence \t within double quotes is parsed as a tabulation character. Change double quotes to single quotes:

system('cmd /c C:\wamp64\www\test.bat');

Also, I don't think you need to run cmd explicitly, since batch files are executable on Windows.