See if this works. I wemmed about with all the exec stuff ages ago and this is from my stack of examples I keep, can you use this instead?
<?php
/**
* For a command like notepad to show a window when running under apache as a service
* have to set the option 'Allow apache to interact with desktop' in the log on tab
* in services. Restart the service each time a
*/
shell_it('notepad.exe', 1, true);
echo "I'm done at: ".date('r');
/**
* exec, shell_exec and backticks getting you down?
*
* @param string command to run
* @param int window style
* @param bool wait before returning - set to false and it will run in bg
*/
function shell_it($cmd, $winStyle = 0, $waitOnReturn = false)
{
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($cmd, $winStyle, $waitOnReturn);
$WshShell->Release();
return $oExec;
}
/*
Ok modes Actually here: http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/wsh/htm/wsMthRun.asp
0 Hide the window and activate another window.
1 Activate and display the window. (restore size and position) Specify this flag when displaying a window for the first time.
2 Activate & minimize.
3 Activate & maximize.
4 Restore. The active window remains active.
5 Activate & Restore.
6 Minimize & activate the next top-level window in the Z order.
7 Minimize. The active window remains active.
8 Display the window in its current state. The active window remains active.
9 Restore & Activate. Specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application
If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application.
If bWaitOnReturn is not specified or FALSE, this method immediately returns to script execution
rather than waiting on the process termination (and returns an error code of 0)
Specifying the bWaitOnReturn parameter allows you to run programs synchronously (one at a time).
Using 0 never shows a phpcli window at all in the taskbar
Using 7 shows it, but just in the task bar, it doesn't focus
*/
?>