Skip to content
mnaoumov.dev
Go back

Windows Task Scheduler silently fails

Hi folks

Today I’ve discovered an issue which I would like to share.

We had a Task Scheduler task which runs cmd, and that cmd runs robocopy to backup some files to the network drive.

I’ve been asked to investigate why it is not working and not showing any errors.

According to the TaskScheduler event log: task completes within with event type 201

Task Scheduler successfully completed task "\Mytask" , instance "{b35cde71-a3d3-46fc-9ee7-be66e54a5636}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 0.

After some head scratches I found the root cause

Firstly, it started to work when I enabled Run only when user is logged on

run-only-when-user-is-logged-on.jpg

Previously it was Run whether user is logged on or not

The drawback of the second mode is that the running process windows are hidden so we cannot see what is going on.

And after some googling I found that in this mode none of mapped drives will work

http://www.networksteve.com/forum/topic.php/Running_Scheduled_Task_using_%22Run_whether_user_is_logged_on_or_n/?TopicId=10304&Posts=0

And here is the solution for that

http://modmaven.wordpress.com/2009/05/27/how-to-make-windows-7-map-your-network-drives-properly/

Set-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnection -Value 1 -Type DWord

Share this post on:

Previous Post
PowerShell 3 - Attempting to perform the InitializeDefaultDrives operation on the FileSystem provider failed
Next Post
NUnit issue