Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- exec hide dos box
- Hendri Adriaens
March 6, 2007, 9:28 am
rate this thread
I succeeded in finding a workaround for the quotation bug in exec that
caused an error in the apache error logs. here it is:
exec('start "zip" /B "'.$winzip_path.'\wzzip" -m -s'.$password.'
But unfortunately, the /B switch doesn't do it's job, I still see the dos
box. Is there a way to suppress it?
I found the script that is posted below, but that doesn't wait for winzip to
finish. Is there any solution that I can run winzip without a dos box and
that php waits for winzip to finish?
Thank you, best regards,
// runs a command line and returns
// the output even for Wind XP SP2
// example: $cmd = "fullpath.exe -arg1 -arg2"
// $outputString = windExec($cmd, "FG");
// OR windExec($cmd);
// (no output since it runs in BG by default)
// for output requires that EXEC_TMP_DIR be defined
// Setup the command to run from "run"
$cmdline = "cmd /C $cmd";
// set-up the output and mode
$outputfile = EXEC_TMP_DIR . "\" . time() . ".txt";
$cmdline .= " > $outputfile";
$m = true;
else $m = false;
// Make a new instance of the COM object
$WshShell = new COM("WScript.Shell");
// Make the command window but dont show it.
$oExec = $WshShell->Run($cmdline, 0, $m);
// Read the tmp file.
$retStr = file_get_contents($outputfile);
// Delete the temp_file.
else $retStr = "";
Re: exec hide dos box
It's opening a command line prompt because you can't run a command line
program in a windowed session - at least not without some workarounds.
What you're running into is Windows limitations, not PHP. I'd recommend
you ask in a Windows newsgroup. Maybe they have some ideas - i.e. other
COM objects you could use.
Remove the "x" from my email address
JDS Computer Training Corp.