title: How to launch a .cmd file using Task Scheduler?
body: <p>I have a folder with a PowerShell script and a .cmd file that executes it (among other things).</p>
  
  <p><a href="https://i.stack.imgur.com/Dq1F5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dq1F5.png" alt="Folder"></a></p>
  
  <p>I want task scheduler to launch <strong>Run.cmd</strong> but it won't work. Manually launching <strong>Run.cmd</strong> works and so does launching just the <strong>.ps1</strong> by itself. Here is how I set up my task scheduler:</p>
  
  <p><a href="https://i.stack.imgur.com/DCNWb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DCNWb.png" alt="Taskscheduler"></a></p>
  
  <h2>Additional information:</h2>
  
  <ul>
  <li><p>The script backs-up our network switches</p></li>
  <li><p>The .ps1 by its nature throws up a few non-critical errors (doesn't stop the script)</p></li>
  <li><p>Run.cmd is this:</p>
  
  <pre><code>@echo off
  powershell.exe -ExecutionPolicy Bypass -file "BackupSwitch.ps1"
  %SystemRoot%\System32\tree.com "%~dp0backups" /f
  TIMEOUT /t 10
  </code></pre></li>
  </ul>