Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Task scheduler can't show GUI of the application after logout and login (run whether user is logged on or not)

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,

like image 887
Ng2-Fun Avatar asked Sep 28 '16 01:09

Ng2-Fun


People also ask

Does Task Scheduler work when user is logged off?

Task scheduler cannot open batch file when set to run whether user is logged on or not. Bookmark this question. Show activity on this post. It runs successfully on its own.

Can Task Scheduler run in background?

By default, when you create a new scheduled task, the task is set to Run only when user is logged on. As a result of that setting the scheduled task will run in the foreground. 2. If you want to run the scheduled task in background (hidden), then select the Run whether user is logged on or not option and click OK.

How do I run a Task Scheduler as a different user?

Highlight the name of the scheduled task you want to change, go to the File menu and click Properties, and select the Task tab. In the "Run as" box, type the account name to use. Click "Set password." Type the user account password in the "Password" and "Confirm password" fields, then click OK.

Can runs scheduled task manually but not automatically?

If the scheduled task works when you run it manually, but doesn't work automatically, take a closer look at its arguments. You can use other dedicated third-party solutions to create computer tasks and to monitor processes or services. When your scheduled tasks are not working, make sure to check if they are enabled.


1 Answers

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.

like image 100
amaidment Avatar answered Oct 05 '22 23:10

amaidment



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!