Link to home
Start Free TrialLog in
Avatar of madmin
madmin

asked on

Server 2012 R2 scheduled tasks works when logged off, except when "Repeat task every" checkbox is used

I need to run an Excel VBA module every 10 minutes from my 2012 R2 server. I am using a VB script to launch it:

Dim eApp
Set eApp = GetObject("\\server.ADdomain\share\dir\exelfile.xlsm")
eApp.Application.Run "exelfile.xlsm!vbaModule"
Set eApp = Nothing

Open in new window


I had a scheduled task starting cscript using this vbs file as an argument. I have now changed the task to run a cmd script so I can log errors. Here is the cmd script:

C:\Windows\System32\cscript.exe C:\temp\vbscript.vbs > c:\temp\taskschlog.txt 2>&1

Open in new window


The scheduled task works properly when it is set to "Run whether user is logged on or not" when the Trigger is set to Daily at a specified time and I log out of the server. However, if I leave everything else the same, except I change the Trigger settings, checking the box for "Repeat task every" and setting its timing drop downs, and then log out of the server, it stops working! The cmd script error log shows:

C:\temp\vbscript.vbs(2, 1) Microsoft VBScript runtime error: Permission denied: 'GetObject'

Open in new window


I've read A LOT on various task scheduler issues, but mostly people have issues getting it to run when the user is not logged in, which is not my issue; it's the "Repeat task every" functionality. How does this setting suddenly create a permission error?
Avatar of Ganesh Anand
Ganesh Anand
Flag of Bahrain image

Avatar of madmin
madmin

ASKER

Thank you for that link. I read through the entire thread. The final fix there was to enable DCOM which had become disabled unbeknownst to the admin. Unfortunately this is not the case on my server.

I think the key is the "Repeat task every" attribute when it is used with the "Run whether user is logged on or not" functionality. The task works when logged out without the "Repeat task ever" box checked, but does not work when logged in or out with it checked.

Just so it's clear:
CHECKED - Run only when user logged on
CHECKED - Repeat task every

Open in new window

^ WORKS When logged on (N/A when logged off)

CHECKED - Run whether user is logged on or not
UNchecked - Repeat task every

Open in new window

^ WORKS When logged on or off

CHECKED - Run whether user is logged on or not
CHECKED - Repeat task every

Open in new window

^ DOES NOT WORK When logged on or off


How does the "Repeat task every" attribute affect the way the scheduled task is run? Even Windows Internals 6th edition research has come up fruitless; it makes no mention of this attribute or the guts of the Task Scheduler that I can find.

Also noteworthy is that I moved all files referred to by the task and its scripts to the local disk to take networking out of the equation; the behavior remains the same.

Looks like I'm not the only one. I'm on version 6.3 build 9600.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.