6

I have a GUI application, and I hope it auto run after reboot/logout windows computer.

Here is how I use windows task scheduler:

  1. first run a command to create a task: c:\Windows\System32\schtasks.exe /Create /TN taskname /XML taskname.xml /RU username /RP password /IT

  2. after the task was created, in the general tab, "Run whether user is logged on or not" radio button was selected, and "Do not store password" checkbox wasn't checked. in triggers tab, I set to repeat the task in every 5 minutes. enter image description here

After reboot the computer, it can auto trigger the app to run and show the GUI in 5 minute. However, if I logout and then login the computer, it will only trigger the app to run without showing the GUI, I have been waiting for about 10 minutes, I can only see the process of app is running in task manager. Unless I manually end the task and then run the task, it will run the app with a GUI.

Does anyone know why it happened and how to fix it?

Thanks,

Ng2-Fun
  • 3,307
  • 9
  • 27
  • 47
  • This question should probably be on SuperUser, rather than StackOverflow. Indeed, arguably it's a duplicate of this question on SuperUser: http://superuser.com/questions/78359/why-is-windows-7-scheduled-task-running-hidden – amaidment Dec 07 '16 at 10:47

1 Answers1

10

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.

amaidment
  • 6,942
  • 5
  • 52
  • 88
  • yes, I have figured out that. Thanks for your info. – Ng2-Fun Dec 07 '16 at 13:55
  • FYI - I found a workaround, which I have described in my answer to my own similar (but slightly different) [SO question](http://stackoverflow.com/questions/41015796/running-visible-applications-using-java-processbuilder-from-a-process-started?noredirect=1&lq=1). – amaidment Jan 03 '17 at 17:16
  • Unbelievable that it's not possible to start an app with interface automatically after the reboot of a Server 2019! I have wasted a few hours to see (can't believe) Thanks MS! – FredyWenger Oct 05 '20 at 10:14
  • That's Microsoft for you. A small print to say "Will/will not display GUI" must be giving them a hard time. I guess the programmers are doing both coding and UI/Ux – Ishmael Mavor Raines Jul 31 '23 at 08:42