Link to home
Start Free TrialLog in
Avatar of jbanjo
jbanjo

asked on

Task Scheduler: MS Access 2010 "Run whether user is logged on or not"

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
C:\Windows\System32\Tasks\

I also checked to make sure that the registry was creating the appropriate reference (I will NOT make any changes to my registry):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks

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)

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I should add I've also had problems with task scheduler itself and older versions of Access.  I've got one client where when run from task scheduler on Windows server 2003, it often generates a C000005 error.

Works fine in every other way, just has a problem quitting.

I worked aound that by configuring Dr Watson to log the fault, but not do anything else with it.

Jim.
Avatar of jbanjo
jbanjo

ASKER

Thanks Jim.

I have a QuitAccess command at the end of my macro (no saving, and warnings disabled on the macro), and it works well when I'm logged on.  I've read that using VBA to perform this quit is more reliable, but I would still have to call on it via the macro or have it execute when the macro completes.

I had changed any mapped drives to their full paths, but still no resolution.

If there is not a way to run Access unless logged in (or do so effectively and consintently), I think that my best solution is to “Run only when user is logged on” and lock my computer each night before I leave.  If a restart occurs, I can have the task launch at my next login.  I will track report execution times in Access and, on the event that a particular night is skipped, a macro can have the report run for each night since the last successful execution.

Please let me know if you think of a better alternative.

Thanks!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial