cmd /k start /B /MIN c:\chemin vers le script
<?php $c_apacheExe = 'j:/wamp/bin/apache/apache2.4.37/bin/httpd.exe'; //Get Apache variables (Define) $c_ApacheDefine = array(); $command = "start /b /min /wait ".$c_apacheExe." -t -D DUMP_RUN_CFG"; $output = `$command`; if(!empty($output)) { if(preg_match_all("~^Define: (.+)=(.+)\r?$~m",$output, $matches) > 0 ) $c_ApacheDefine = array_combine($matches[1], $matches[2]); } ?>Que ce soit avec les guillemets obliques (comme ici), system(), passthru(), exec() la fenêtre s'affiche toujours.
<?php $result = shell_exec('.\batch.bat'); ?> <pre> <?php echo iconv("Windows-1252", "utf-8", $result); ?> </pre>Aucune fenêtre s'ouvre !
Citation
Otomatic
S'il faut passer pas un fichier supplémentaire et un étage de plus... à voir.
Citation
Otomatic
Ça ne change rien : la documentation PHP dit : shell_exec() est identique aux guillemets obliques.
Citation
Otomatic
Il faut aussi voir si le script est lancé par php.exe ou par php-win.exe.
<!doctype html> <html> <?php header('Content-Type: text/html; charset=utf-8'); ?> <head> <meta charset="utf-8" /> <title>Commandes !</title> <link rel="stylesheet" type="text/css" href="Styles.css"> </head> <body> <h1>Commande shell_exec()</h1> <?php $result = shell_exec('dir'); ?> <pre> <?php echo iconv("CP850", "utf-8", $result); ?> </pre> <?php $result = shell_exec('php.exe ./test.php'); ?> <pre> <?php echo $result; ?> </pre> <?php $result = shell_exec('.\batch.bat'); ?> <pre> <?php echo iconv("Windows-1252", "utf-8", $result); ?> </pre> <h1>Commande System()</h1> <pre> <?php system('date /T'); system('time /T'); ?> </pre> </body> </html>Il ne s'agit pas d'un batch php lancé en mode cli.
Type: item; Caption: "Lancement"; Action: shellexecute; FileName: "C:/Users/Patron/Desktop/Lancer"; WorkingDir: "C:/Users/Patron/Desktop/"; Glyph:9
Type: item; Caption: "Lancement"; Action: run; FileName: "%PhpVisu%"; WorkingDir: "C:/Users/Patron/Desktop/"; Flags: waituntilterminated; Glyph: 9; Parameters: "-c . Script.php"Dans cet exemple, il s'agit de "php-win.exe". Mais avec "php.exe", la fenêtre s'ouvre mais aucun affichage.
ShowCmd: hidden;