title: How to open an Excel file directly from a Powershell script?
body: <p>I'm using Powershell version 7.2.1</p>
  <p>When I run the command below on Powershell, it works fine, i.e. Excel is launched and the target Excel file is opened.</p>
  <pre><code>&amp; 'PATH_TO_EXCEL_EXE' 'PATH_TO_TARGET_FILE'
  </code></pre>
  <p>Howewer, when I pass this command to a scheduled task, Excel is launched but the target file isn't opened. More details about my Powershell script:</p>
  <pre><code>$action = New-ScheduledTaskAction -Execute &quot;&amp; 'PATH_TO_EXCEL_EXE' 'PATH_TO_TARGET_FILE'&quot;
  ...
  Register-ScheduledTask -Action $action -Trigger $trigger -TaskName &quot;myTask&quot;
  # The line below is for testing purpose, to see if my scheduled task can launch correctly.
  Start-ScheduledTask -TaskName &quot;myTask&quot;
  </code></pre>
  <p>Can someone tell me the reason why Powershell fails to replicate the action, when it's passed to a scheduled task as above? Any workarounds/solutions would be appreciated.</p>