A workaround for the fact that a scheduled task in Windows requires a user to be logged in

Viewed 52863

I am running a small executable created by a third party that needs to run at regular intervals on a Windows 2008 server. This executable effectively ETLs information from one system to another and needs to run every hour or so around the clock. As part of its processing the executable launches a small Windows Forms type UI.

I have set up a scheduled task to call the file and this works ONLY if the user under which the task is configured to run is logged onto the machine (either locally or via Remote Desktop). If I set the task to run as another user, or set the task to run when the user is not logged, on the scheduled task executes and errors. I have tried running as different users including Administrator user and System user. Is there any possible workarounds (without changing the third party code which I have no access to) which would allow this code to be run without a specific user logged in.

8 Answers

This looks to be an old thread, but I recently ran in to this in my organization due to UAC requirements they were not using. I am still testing this, but I believe you can still enable interactive mode on a scheduled task by using the /Change command on the task and adding the /IT flag to make it interactive. Referenced here: https://docs.microsoft.com/en-us/windows/desktop/taskschd/schtasks

schtasks /Change /tn "Task A" /IT /RP "password of user if used"

My initial tests show this to be working, however I cannot noticeably see a difference to the task in task scheduler when I do this. So, I am not sure of how to verify if it is set to do this.

I had a similar issue. My VB app would not run properly on my server unless I had "Run only when user is logged on" enabled. I forget where I found this info, but doing it allowed my VB app to run perfectly with a set user, without needing to be logged in. It allows it to interact with the Desktop.

On a Windows 2008 (or greater) server, you need to do the following:

For x64, just create this folder: C:\Windows\SysWOW64\config\systemprofile\Desktop

For x86, just create this folder: C:\Windows\System32\config\systemprofile\Desktop

Related