title: Batch File running fine if double-clicked but does not run in Windows Scheduled Task
body: <p>I have an archive.pst file on my C: drive that I use in outlook to backup my email. But my C: is not backed up each night. So I'd like to copy the .pst file to my network drive so it will consistently be backed up. I do not want outlook to open the .pst file directly from the network drive for a variety of reasons.</p>
  
  <p>Therefore I am trying to create a scheduled task that will copy my .pst file to a network location each day. The batch file below works perfectly if double-clicked. If I try to run the scheduled task, only the log file is created. Outlook doesn't close and the .pst file is not copied. I've tried running with the highest privileges but that doesn't seem to help. Any ideas would be appreciated.</p>
  
  <pre><code>cscript.exe close_outlook.vbs
      ::This is my VBS Script
          ::Set Outlook = CreateObject("Outlook.Application")
          ::Outlook.Quit
  
  ping localhost &gt; nul
  
  set idrive="\\myserver\drive\\Outlook Files\"
  set current="C:\myfolder\myuser\Documents\Outlook Files"
  
  echo Start Time of Copy: %time% &gt;&gt; %idrive%\Log.txt
  copy %current%\archive.pst %idrive%\archive.pst /y
  echo End Time of Copy: %time% &gt;&gt; %idrive%\Log.txt
  
  move %idrive%\Log.txt %idrive%\BackupLogs\Log.txt
  ren %idrive%\BackupLogs\Log.txt %date:~10,4%-%date:~4,2%-%date:~7,2%_log.txt
  
  cscript.exe open_outlook.vbs
      ::This is my VBS Script
          ::set shell = createobject("wscript.shell") 
          ::shell.run "outlook.exe"
  EXIT
  </code></pre>