1

I have a Windows Server 2016 VPS with Plesk and PHP 7.1x.

I am trying to execute a simple AutoHotKey script from PHP using the following command:

<?php shell_exec('start /B "C:\Program Files\AutoHotkey\AutoHotkey.exe" C:\inetpub\vhosts\mydomain.com\App_Data\myahkscript.ahk'); ?>

This is the only line on the page. I have tried different ahk scripts, the current one simply creates a MsgBox.

When I execute my php page, on VPS Task Manager I see three processes created with the expected USR: cmd.exe, conhost.exe and php-cgi.exe. However, my PHP page just sits waiting on the server and nothing actually happens on the server.

I have also tried the same line except replacing shell_exec with exec. This seems to make no difference. I have tried without start /b with both commands. In that case the PHP page completes but no new processes are started.

I cannot find any errors in any logs: Mod_Security, Plesk Firewall, IIS.

Any ideas?

EDIT: I tried my command from the VPS command prompt and immediately slapped in the face with the obvious issue of the space in 'Program Files'. I quoted the string as shown above and the command works. This eliminated the hang when running from PHP. However, the command still does nothing when executed from the web page.

EDIT: Based on suggestions from the referenced post 'debugging exec()':

var_dump: string(0)""
$output: Array()
$return_val: 1

One point was that I would probably not be able to invoke GUI applications. That puts a damper on the idea.

Trialsman
  • 329
  • 3
  • 14

0 Answers0