Task Scheduler: MS Access 2010 "Run whether user is logged on or not"
Posted on 2013-01-25
I need a solution to run Microsoft Access 2010 macros overnight on Windows 7, using "Run whether user is logged on or not" in Windows Task Scheduler (Start > Control Panel > Administrative Tools > Task Scheduler). Though I use a domain login, I have administrative rights to my computer. I have no issue executing batch files for simple tasks: the issue seems specific to Access.
I didn’t have any problem to “Run only when user is logged on”—even if I had my profile locked. However, my IT department often restarts computers overnight/weekends to push updates, which would render this option unviable.
Windows task scheduler gives the option to “Run whether user is logged on or not,” which would have required only that my workstation be turned on. However, I have been unable to get Microsoft Access to execute when the user is logged off (and the Task is stuck on “Running”, unless given a timeout, in which case it will think that it executed properly.)
This is the Task that I created to launch Microsoft Access:
Program/Script: C:\Windows\System32\cmd.exe (If I try to execute Access directly from Task Scheduler when logged off, a .laccdb Access lock file is created but will not clear, and the task never executes)
Arguments: /c start "" "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" C:\TestAccessDB.accdb /X RunMacro
When performing the same task by writing the argument to a batch file (which is what I will do when I have multiple reports that I want to run consecutively), I had the same outcome.
Whenever I selected “Run with highest privileges” and manually executed, I received an error in Access: “Microsoft Access can’t change the working directory to ‘P:\Data’ (mapped network drive). Verify that the drive is valid and the path is 260 characters or less in length.”
Note: There were three server options. Windows Server 2003 was the only option that worked when I executed the task manually.
With administrator rights, I gave myself “Log on as batch job” rights:
Start > Control Panel > Administrative Tools > Local Security Policy, then Local Policy, User Rights Assignment, Logon as batch job
I granted myself Full Permissions to:
C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE
I also checked to make sure that the registry was creating the appropriate reference (I will NOT make any changes to my registry):
To ensure that this was an Access issue, I ran a test and scheduled the command prompt to execute a batch file, which in turn executed a simple log file. I logged off of my computer, waited for the scheduled time to pass, and logged back in. My test worked properly, confirming that the issue is with Access.
Due to company security protocol, I am unable to disable “Users must enter a user name and password to use this computer” in User Accounts. (If I were able to enable this feature, I would write the following to a batch file, then schedule a Task for this batch file to execute at login: rundll32.exe user32.dll,LockWorkStation)