2

I'm trying to open video player in windows 7 with PHP but can't seem to make it happen. The only way it works is in background - I can hear the sound and it's in the process list but I can't see the video player itself. It's not listed in taskbar or in notification area.

I've tried with exec command and with COM class using WScript.Shell. I even tried with start in front of the command line but still nothing. If I use the same line in cmd.exe, it works, player pops up and starts playing but with php, it starts in background or doesn't start at all.

Code I use is following:

exec('start "C:\Program Files\Daum\PotPlayer\PotPlayer.exe" "D:\mov.avi"');

and

`$w = new COM("WScript.Shell"); $o = $w->Run('"C:\Program Files\Daum\PotPlayer\PotPlayer.exe" "D:\mov.avi"', 1, false);

--Edit--

This happens to me all the time - just after you've searched for long time and lost all hope you post your question. In next 10 minutes you lay back and just browse and you find answer to the question.

Anyway, I got this to work.Run -> services.msc find apache server service and choose properties. Log on tab and check 'allow service to interact with desktop'. Restart apache and last script works. Windows will ask if you want to view the message, just click yes and video starts to play. Before you click return to desktop, be sure to close the video player window, otherwise it will stay playing and you have to stop it from task manager. `

2 Answers2

0

If you start web server by System. PHP process and child process is run by "system" and process is in background.Try to start web server manually.

0

You should not rely on "allow service to interact with desktop", as it may lead to problems. (In fact, wasn't it supposed to be removed in Windows 7?)

The reason this isn't working for you is because of Session-0 isolation. Basically, the services run in a completely different space as the user. Processes can execute, but the user won't be able to directly interact. If you check that "allow service to interact" box, this breaks down that wall, but I wouldn't bank on it forever.

http://msdn.microsoft.com/en-us/windows/hardware/gg463353

Brad
  • 159,648
  • 54
  • 349
  • 530
  • So basically it's impossible to open video player in foreground that user can see and interact with php without creating any PHP extentsions? –  Jul 20 '11 at 19:50
  • 1
    What you need is some form of inter-process communication. This could be as simple as a queue of commands in a database or file, or as robust as shared memory. See http://stackoverflow.com/questions/1746207/how-to-ipc-between-php-clients-and-a-c-daemon-server or http://www.re-cycledair.com/php-dark-arts-shared-memory-segments-ipc. You might also be able to instantiate some sort of .NET remoting. – Brad Jul 20 '11 at 20:05