0
votes

Recently we updated our systems to Office 2016. I have a scheduled task that reads information in an MS Access DB and then sends this information to a mail recipient via Outlook. All was fine until the upgrade.

The Scheduled task launches a .bat file which opens MS Access, calls a function, performs a task and then send the the information via email using outlook.

When I run the batch file manually by double clicking on it, it works as intended and sends the email. However, when I run through Task Scheduler it does not work. I know for certain that it opens the MS Access file and can read, but for some reason it fails to send the email. I have lowered all security setting to no avail.

The scheduled task runs with the highest privileges and all was fine before the upgrade.

Does anyone have any suggestions.

2
Can you post the .bat file script? Possibly, this is a path issue. How does running .bat at command line in PowerShell work? Clicking directly a .bat file uses relative paths while outside absolute paths are needed. Also, your .exe or environmental variables may have changed directories in upgrade.Parfait
'c: cd\Program Files (x86)\Microsoft Office\Office16 msaccess.exe "C:\autojobs\autojobs2.accdb" /x AUTO_JOB_ACTIVEWITHNOACTIVEPRIME ' **The batch file runs perfectly when I double click on it. However, when I run through Task Scheduler I know it performs the necessary tasks in Access but fails to send email via Outlook. This all started when we upgraded to Outlook 2016 on Win 7. Urrggg very frustrating! Also, I made a batch file that just opens Outlook. Again, works fine manually, through Task Manager nothing happens.user3297770
OK-When I change the properties in Windows Task Scheduler to Run Only when user is logged in, from Run whether user is logged in or not. It works perfectly. However, this was not the case before the office upgrade.I am hoping there is policy or reg I can modify to correct this. Any ideas?user3297770
if outlook is not recomended, you can use smtp via CDO stackoverflow.com/q/11579730/6269045, then outlook is not involved.BitAccesser

2 Answers

0
votes

Outlook has security settings that will prevent an application from sending e-mail through it programmatically. It will use a popup dialog to ask for permission to send the e-mail. While I have successfully gotten rid of the popup and made Access send through Outlook while Outlook is open (both manually and as a scheduled task), it still fails when Outlook is not already open.

Your best bet, if you have the capability, is to leave Outlook open on the machine that runs the scheduled task. Otherwise you have to try to figure out what combination of policies and registry/outlook settings will make Outlook work the way you want it to.

Edit: My experience is with a windows domain/local exchange server environment.

0
votes

We upgraded to Office 2016 a few weeks ago, and had been facing the same problem as you. Our batch file runs Access and triggers a macro that exports some data to a text file, and works fine when run manually. However, when run through Task Scheduler, everything seemed to run fine, but the text file was never updated. After trying for weeks with no success, I finally found the reason for the problem, and a solution.

In our case, the problem was that Access 2016 wants to be run as a foreground app. But when running as a Task Scheduler app (with the "run whether user is logged on or not" option checked), it views itself as a background app and therefore won't run. See Jim Dettman's answers here for a bit more on that: https://www.experts-exchange.com/questions/28988837/

Next, I found this post by Microsoft employee Blake Morrison where he discusses the changes in the latest version of Task Scheduler. One of his troubleshooting suggestions worked for us:

Try creating a new task, but select the Configure for: option to be “Windows Server 2003, Windows XP, or Windows 2000” – this will create an XP/2003 fashioned task

Unfortunately you probably have to do this as a new task - existing tasks don't seem to allow you to choose this option (it didn't show up in the dropdown menu for my existing task). So my settings for the new task are:

  1. Running as an administrator account
  2. "Run whether user is logged on or not" - checked
  3. "Run with highest privileges" - checked
  4. Configure For: Windows Server 2003, Windows XP, or Windows 2000

If I manually trigger the task, I see a command prompt open, then Access briefly opens and disappears (our macro has a Quit Access command at the end), and then the command prompt disappears. Output to our text file is written as expected. If I schedule it to run while I'm logged out of the machine, obviously I see nothing, but the text file is again written as expected, so I know it worked.