1

Please take a look at this thread :
Task scheduler can't show GUI of the application after logout and login (run whether user is logged on or not)


This seems to be the way that recent versions of Windows TaskScheduler.

According to Microsoft (emphasis added):

You can specify that a task should run even if the account under which the task is scheduled to run is not logged on when the task is triggered. To do this, select the radio button labeled Run whether user is logged on or not . If this radio button is selected, tasks will not run interactively. To make a task run interactively, select the Run only when user is logged on radio button.

Essentially, if you select 'Run whether user is logged on or not', the process will not start a UI.


I need to start app before user's login.
So i chose Run whether user is logged on or not radio button.
But in this mode i can't see GUI after login.
I need a trick in c# or other way to show that app's UI after login.

SilverLight
  • 19,668
  • 65
  • 192
  • 300
  • Looks like you need to "listen" to login event, see: https://stackoverflow.com/questions/16282231/get-notified-from-logon-and-logoff – Mark PM Jan 28 '21 at 18:07
  • 2
    Even if you do create a GUI before a user logs in, it will be attached to a different window station, and thus not visible to the user when their interactive window station is created. You pretty much need to make a GUI-free service or scheduled task, and have a app launched when the user logs in that uses some form of IPC to show the status of the task. – Anon Coward Jan 28 '21 at 18:18
  • 1
    You need to separate the services of your application from UI. The service could be a Windows Service or a console application which runs before startup. The UI could be a Windows Forms Application which runs after user login. To communicate between the service and the windows Application, you can use an IPC solution. – Reza Aghaei Jan 28 '21 at 18:25
  • You seem to be misunderstanding **If this radio button is selected, tasks will NOT RUN INTERACTIVELY**. *Will not run interactively* means that there will be no GUI displayed and the application cannot be interacted with when it is run. If you want a GUI, you need to run it as a logged in user, so that a desktop exists on which the GUI can be run. – Ken White Jan 28 '21 at 18:25
  • Would you please show me a good tutorial about IPC forms? This is totally new world for me. How that background app can update GUI one? If GUI is not open what happens to the background app? – SilverLight Jan 28 '21 at 18:29
  • 1
    A step by step example using WCF + console applications: [Send information between applications](https://stackoverflow.com/a/32694012/3110834) – Reza Aghaei Jan 28 '21 at 18:37
  • 1
    Another example using ASP.NET Core API + WinForms: [Hosting ASP.NET CORE API in a Windows Forms Application and Interaction with Form](https://stackoverflow.com/a/60046440/3110834) – Reza Aghaei Jan 28 '21 at 18:39
  • 1
    By the way, if you don't mention people in the comment, there's less chance they come back and check the comments here. You need to mention them like @SilverLight – Reza Aghaei Jan 28 '21 at 18:42
  • @Reza Aghaei this is so interesting. What about a console application and winform ipc without wcf? – SilverLight Jan 28 '21 at 18:57
  • You're welcome :) For WinForms + Console App, I believe a self hosted WCF service or a Self hosted Web API is the best option. – Reza Aghaei Jan 28 '21 at 19:14

0 Answers0