dcsimg
Results 1 to 2 of 2
  1. #1

    Thread Starter
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    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
    Code:
    -NonInteractive
    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
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,144

    Re: Trick the Environment.UserInteractive from command shell?

    I think that it has to do with how Windows runs your application. The doco says:
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width