Launch a hidden application window
4 posts
• Page 1 of 1
Launch a hidden application window
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.
- Antilles
- Posts: 6
- Joined: September 13th, 2015, 10:10 pm
Re: Launch a hidden application window
Addition: Namespace calls:
Included libraries from compilation config:
I'm using console compiler (PHPC) of Phalanger 3.0.
- Code: Select all
use System;
use System\Management;
use System\Diagnostics;
Included libraries from compilation config:
- Code: Select all
<add assembly="mscorlib" />
<add assembly="PhpNetClassLibrary, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4af37afe3cde05fb" />
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
I'm using console compiler (PHPC) of Phalanger 3.0.
- Antilles
- Posts: 6
- Joined: September 13th, 2015, 10:10 pm
Re: Launch a hidden application window
Hi,
First try to switch to Phalanger 4.0 (https://visualstudiogallery.msdn.micros ... cf66037797)
Then, accessing members in PHP uses operator ::. (\ is for namespaces, . is for string concatenation).
Also note, 'use' in PHP has a different meaning than in C#.
use System\Diagnostics; is equivalent to use System\Diagnostics as Diagnostics;
Then you should write Diagnostics\ProcessWindowStyle, not just ProcessWindowStyle.
First try to switch to Phalanger 4.0 (https://visualstudiogallery.msdn.micros ... cf66037797)
Then, accessing members in PHP uses operator ::. (\ is for namespaces, . is for string concatenation).
- Code: Select all
System\Diagnostics\ProcessWindowStyle::Hidden
Also note, 'use' in PHP has a different meaning than in C#.
use System\Diagnostics; is equivalent to use System\Diagnostics as Diagnostics;
Then you should write Diagnostics\ProcessWindowStyle, not just ProcessWindowStyle.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: Launch a hidden application window
Thank you Jakub! I just used the :: operator and solved my issue.
I can't install Phalanger 4.0 because my app requires .Net Framework 3.5 compatibility (for target machines that running Windows XP). So I keep using Phalanger 3.0. So far, so good.
I can't install Phalanger 4.0 because my app requires .Net Framework 3.5 compatibility (for target machines that running Windows XP). So I keep using Phalanger 3.0. So far, so good.
- Antilles
- Posts: 6
- Joined: September 13th, 2015, 10:10 pm
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 8 guests