Launch a hidden application window
Posted: November 2nd, 2015, 3:43 pm
My app uses an external console application to complete its task but I couldn't figure out how to launch it without creating a console window. Here's the code I'm using:
This launches the app, but creates a console window.
Also, upon execution, I'm getting following error messages:
I also tried the following method:
Upon execution:
for line $app->Arguments($arguments);
This doesn't even launch the application (although it used to, I must have messed it up).
Could you help me to assign the necessary attributes to my Process or ProcessStartInfo object? Thank you.
- Code: Select all
$arguments = " /foor /bar";
$app = new System\Diagnostics\Process;
$app->StartInfo->CreateNoWindow = true;
$app->StartInfo->WindowStyle = ProcessWindowStyle.Hidden;
$app->Start("app.exe", $arguments);
This launches the app, but creates a console window.
Also, upon execution, I'm getting following error messages:
Notice: Use of undefined constant ProcessWindowStyle - assumed 'ProcessWindowStyle' in C:\Program Files\Phalanger 3.0\Bin\program.php on line 1111, column 1.
Notice: Use of undefined constant Hidden - assumed 'Hidden' in C:\Program Files\Phalanger 3.0\Bin\program.php on line 1112, column 1.
I also tried the following method:
- Code: Select all
$arguments = " /foo /bar";
$app = new System\Diagnostics\ProcessStartInfo;
$app->Filename("app.exe");
$app->Arguments($arguments);
$app->WindowStyle = System\Diagnostics\ProcessWindowStyle\Hidden;
$app->UseShellExecute = false;
$app->Start();
Upon execution:
Error: Call to undefined method: System\Diagnostics\ProcessStartInfo::FileName() in C:\Program Files\Phalanger 3.0\Bin\program.php on line 1111, column 1.
for line $app->Arguments($arguments);
This doesn't even launch the application (although it used to, I must have messed it up).
Could you help me to assign the necessary attributes to my Process or ProcessStartInfo object? Thank you.