How to run an Access script using windows task scheduler

1

1

I have a VM running Windows Server 2008 R2 Enterprise and want to use the Task Scheduler to run an Access script. This script will do some stuff and then close. I've already written and tested the command line in a batch file and it works perfectly:

"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" "C:\MyPath\Mydb.accdb" /x "MyMacro"

I've also created a task in the scheduler. I think it opens up the MSACCESS.EXE and passes the other 2 parts of the command line as arguments.

However, when I manually run this in the scheduler, nothing happens. According to the logs, the task is started and then nothing. Looking in the Task Manager, I don't see Access running.

Did I set up the task wrong? The last task scheduler I used was Windows XP (which was very simple compared to this).

Edit

I've also tried this without the arguments, just using "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" for the action. I would expect Access to open, but still nothing happens.

PowerUser

Posted 2013-09-13T15:01:07.840

Reputation: 244

Have you set the Action as Start a Program? – Yass – 2013-09-13T16:30:45.527

@yassarikhan786, yes. – PowerUser – 2013-09-13T17:03:23.093

In which user context does the scheduler run the MS Access? Does that user have sufficient access rights to the .accdb file? – Michał Sacharewicz – 2013-09-13T20:29:25.183

I am using my own user account and "run with highest privileges" is checked. Also, I can successfully run this command line from a batch file. – PowerUser – 2013-09-13T21:30:52.793

The History tab seems to always stop at Event#129:"Created Task Process". – PowerUser – 2013-09-13T21:33:31.567

I've recreated what you did (using simple, fresh file with simple macro writing text to file) and after launching the command from scheduler, it... works :( – Michał Sacharewicz – 2013-09-13T22:49:35.517

Once I run the task, I get following chain of events ID-s: 110-319-100-200-129-201-102, how does it look at your host? Have you separated executable path from arguments, when setting action parameters? – Michał Sacharewicz – 2013-09-13T22:55:34.027

I've removed the parameters (yes, they were separated from the executable path, but at this point I just want to see it open Access). I get 319-100-200-129. Is it opening Access in some hidden manner where I can't see it in the task manager? – PowerUser – 2013-09-13T23:07:04.283

The lack of event 201 at the end of your chain suggests, that Access has been launched and has not been closed afterwards. Which means it works properly. Could you please make and link the screenshots of the task properties tabs: General, Conditions and Settings? – Michał Sacharewicz – 2013-09-14T09:19:27.120

I found half the problem! I was running this 'whether the user is logged on or not', i.e. as a service, meaning it was inivisible to me. Normally, this would be fine, except my script was also throwing an error (and I intentionally haven't included any error handling yet), hence the chain of event IDs was never completing. – PowerUser – 2013-09-20T15:43:07.960

Answers

1

I believe you must select "Run only when user is logged on" in your Windows Task Scheduler Job Properties. You must also be logged on to automatically have scheduled Access macros run.

This really seems like a huge limitation of Access, but I have not seen another solution out there. It would be great to have a solution for running an Access macro while logged off.

Mister_Tom

Posted 2013-09-13T15:01:07.840

Reputation: 502

I don't recall if I did that or not. In the end, I gave up on the VM and just had a user run the script as needed. In hindsight, this turned out to work better for us than my original VM attempt. – PowerUser – 2014-01-31T18:40:17.937