little_webspinner Posted July 27, 2009 Share Posted July 27, 2009 Hello all, this is my first post on this forum so take it easy on me OS:windows XP Environment:Apache/PH5/MYSQL I pride myself on being able to figure things out for myself but I am totally stumped on a problem. I hope someone can help me solve this issue because during my searches for an answer I have found out that I am not the only person who has encounted this issue. I am trying to start a program with by using PHP's Component Object Model (COM) extension/interface. The general snippit of code that I repeatedly encounter is or is much like the the following. <?php $shell = new COM("WScript.Shell"); $shell->Run("notepad.exe"); $shell = null; ?> The run function offers a few parameters that allow you to initialize a (whatever) though the COM, determine the new script/element's windows function/behaviour/style and (more importantly) does not wait for the (whatever) to finsh before continuing on with original php application that initialized the script. The general goal that i am trying to accomplish is to create a way to easily initalize a process/program on a server without hanging up PHP. I can get this to initialize a program but it only runs as a process in the background of windows. I want to be able to run programs in the forground too. The Run Method of the Windows Script Host is supposed to run in a maximized screen if the first parameter is set to three. Assume the last parameter is set to false to avoid php hangups. $run_this = Your program path $WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run($run_this, 3, false); $WshShell = null; Keep in mind, this generally works but it will not lauch programs/windows in a maximized manner, or even visible for that matter. Here are some resources for info regarding this feature. http://us3.php.net/manual/en/intro.com.php http://us3.php.net/manual/en/class.com.php http://www.tuxradar.com/practicalphp/14/1/2 http://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx http://www.somacon.com/p395.php I would like to be able to lauch programs as maximized or minimized windows as well as have them be windowless background processes. If anyone can help it would be greatly appreciated. Thanks all - Little Web Spinner Link to comment https://forums.phpfreaks.com/topic/167576-php-component-object-model-external-programs-on-local-machine/ Share on other sites More sharing options...
little_webspinner Posted August 1, 2009 Author Share Posted August 1, 2009 Nobody can help :'( I think the problem is related to the permissions PHP runs under but I am not sure. I messed things up a bit when I started messing around with my security policies and haven't tried it again since I got everything back in order. The programs launch but to not execute. I have tried other methods such as exec on a batch file but I still have similar issues. Programs launch but do not execute. Linux would be a lot easier to to this kind of thing on. I wish the developers of php would find a way to exec programs in a way that does not hang php. It seems that even if you run a .bat file that has a short instruction list it still hangs until the child process of .bat run their course. COM is a solution for this. It would be nice if there was better documentation for this process. If I ever figure it out I am going to write a tutorial. Interacting with the COM could be such a powerful tool but its kind of a pain to use. Huge security issue too but you can't have one without the other it would seem. Link to comment https://forums.phpfreaks.com/topic/167576-php-component-object-model-external-programs-on-local-machine/#findComment-888553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.