Search code examples
.netexecutioncontext

Get Assembly Execution Context


I am looking a way,to check if my .Net Application has been launched :

  • manually by the user (bu doucble clicking the .exe or a shortcut)
  • by a windows Scheduled task
  • only by using natives .net classes/method
  • not by laucnhing my exe with an optional parameter, and check it on my code

Best regards from Toulouse \ France


Solution

  • Environment.UserInteractive probably suits your needs.

    It indicates weather or not the user is able to interact with the process or not. Which user launched processes probably are, and process launched from IIS/Task scheduler probably aren't.

    https://msdn.microsoft.com/en-us/library/system.environment.userinteractive.aspx