tags:

views:

93

answers:

1

I'm running in a controlled, xp, intranet only environment and I need to start external processes from a PHP applications. (Backups, Reports etc.)

I can get system or exec to start processes that work silently. Here's a simple example

<?php exec ("echo hello > hello.txt");?>

I can get it to execute a bat file that has no visible output.

I can't get any program that has a screen to run such as a report generator or notepad...

<?php exec ("explorer");?>

doesn't do anything. or same for system

+1  A: 

What behavior are you expecting? Calling system('notepad') works fine - it just doesn't display the GUI. It runs in the background, and PHP sits there patiently waiting for notepad to close itself (and only continues if you kill notepad from the process list).

If you're expecting it to pop up a GUI, I'm fairly certain that you can't do that. ;) An option might be to write out a batch script (file_put_contents('runme.bat', 'notepad hello.txt')) and have that batch script queued (with Windows scheduler or whatever the cron-equivalent is on Windows) to run in an async fashion (and clear itself at the end).

Nathan
I see what you mean. You are right notepad is running without a GUI. (My configuration timed out after 60 seconds.) So I can't start a GUI based program out of PHP and have to resort to OS based solutions. It's good to know. thanks !
sdfor