note 116419 deleted from function.exec by salathe

From: Date: Fri, 02 Jan 2015 11:34:03 +0000
Subject: note 116419 deleted from function.exec by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201336@lists.php.net to get a copy of this message
Note Submitter: orlov0562 at gmail dot com ---- Hi there, If you want to pass some parameters through $cmd in solution from "Arno van den Brink" under Windows, keep in mind that you should pass empty double quotes right after "start /B" or as first parameter of $cmd. Example: <?php function execInBackground($cmd) { if (substr(php_uname(), 0, 7) == "Windows"){ pclose(popen("start /B ". $cmd, "r")); } else { exec($cmd . " > /dev/null &"); } } ?> This code will open prj.php in default php editor: <?php $cmd = '"C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\Progr\Prj\scripts\prj.php"'; execInBackground($cmd) ; // full command is: // start /B "C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\Progr\Prj\scripts\prj.php" ?> This happens because "start" parse first parameter as "title" (you can find more information in help for start command: "start /?") So you should put something, for example empty value in quotes before main command: <?php $cmd = '"" "C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\Progr\Prj\scripts\prj.php"'; execInBackground($cmd); // full command is: // start /B "" "C:\Program Files (x86)\Notepad++\notepad++.exe" "D:\Progr\Prj\scripts\prj.php" ?> This code will open prj.php in notepad++ as expected.

« previous php.notes (#201336) next »