note 49257 added to function.exec

From: Date: Fri, 21 Jan 2005 18:28:57 +0000
Subject: note 49257 added to function.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-83737@lists.php.net to get a copy of this message
Ok, well after looking around for a long time on how to execute programs and not have them hanging in the processes in windows I have come up with a solution thats good for me but some of you may laugh. Credit to msheakoski @t yahoo d@t com for the example script above here somewhere. My problem was that I sometimes restart my server remotely and it doesn't turn on my ftp when my computer starts up, I do this so it will start up quicker. But when I want my ftp open I was using a script that executed a .bat from php. However I found this leaves processes running that were dead. I saw msheakoski's solution: <? $WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run("notepad.exe", 3, true); ?> Well I tried sticking in my ftp program executible name where he had notepad.exe. It didn't work. Then I realized that windows will execute anything in the windows directory without including the entire path. So I made a lnk file called FTP.link. I then edited msheakoski's script to: <? $WshShell = new COM("WScript.Shell"); $oExec = $WshShell->Run("FTP.lnk", 3, false); ?> And voila! It runs my ftp program and cmd nor php.exe run in the background dead. Simple yet effective, (just how I like it). Hope this helps you as much as it did me. Brian ---- Manual Page -- http://www.php.net/manual/en/function.exec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49257 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49257&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49257&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49257&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49257&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49257&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49257&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83737) next »