VBS script does not work properly from Task Scheduler in Windows 10
<p>I have a windows server designed to perform mail merges for postal letters.
A outside server generates xls data sheets and SFTPS them to my windows server, along with a JSON file with further instructions: </p>

<ul>
<li>The Letter to merge with (docx file)</li>
<li>An E-mail address to send a PDF of the merged letters.</li>
</ul>

<p>The script works like this:
1. Constantly(every 60 seconds) monitor directory for JSON files. -> 
2. If there is a JSON file, parse it. ->
3. Find XLS file related to that JSON file ->
4. Run VBA/ EXCEL macro to mail merge XLS and the letter into a PDF ->
5. Email PDF to appropriate contact ->
6. Move XLS file to Processed Folder
7. Move JSON file to PRocessed Folder</p>

<p>If I run it manually from the command line it works just fine.  However, If I run it from Task Scheduler, either with "RUN" or automatically when the machine restarts or when a given user logs in the script fails.  Steps 1, 2, and 3 work.  The VBA code/ Macro fails to work.  </p>

<p>I'm hoping this can be resolved through configuration of Task Scheduler.  Here is my current setup:</p>

<p>Script runs from a bat file, the message script keeps a CMD window open that explains what the script is doing:</p>

<pre><code>cscript C:\automerge\message.vbs
cscript C:\automerge\automerge.vbs &gt;&gt; C:\automerge\logs.log
</code></pre>

<p>Task Scheduler Settings:
Run only when user is logged on
Run with Highest Privileges
Configure for Windows 10 (tried using 7 and 8 too)</p>

<p>Trigger:
Trigger at logon - Enabled</p>

<p>Action:
Start a program
Details:
"C:\AutoMerge\JSON Watch.bat"</p>

<p>Conditions:
Start the task only if computer is on AC power
Stop if computer switches to battery power</p>

<p>Settings:
Allow Task to run on demand
If the running task does not end when requested, force it to stop</p>

<p>Can anyone give me advice on how to change the scheduled task or batch file to get this to work?</p>