Trick the Environment.UserInteractive from command shell?
Hi,
the following code:
Code:
Console.WriteLine(Environment.UserInteractive.ToString());
Seems to ALWAYS return true, such as compiled into a Console application, and when executed from a BAT file and ps1 also.
Code:
PS C:\temp> .\EnvironmentTest.ps1 -NonInteractive
C:\temp>.\EnvironmentTest.exe
True
PS C:\temp>
I had hoped the parameter would do the trick. However it does not force it to false.
Is there any way to trick this System.Environment variable that is already compiled into an .exe?
Thanks!
Dave
Re: Trick the Environment.UserInteractive from command shell?
I think that it has to do with how Windows runs your application. The doco says:
Quote:
The UserInteractive property reports false for a Windows process or a service like IIS that runs without a user interface.
It seems like it's about the session that the application is executed in, not the application itself.