note 49257 modified in function.exec by danbrown
| From: | danbrown@php.net | Date: | Sun, 04 Jan 2009 16:29:26 +0000 |
| Subject: | note 49257 modified in function.exec by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-148809@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:
<?php
$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:
<?php
$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
--was--
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
http://php.net/manual/en/function.exec.php