title: psexec is not recognized as an internal or external command while running a batch file from windows scheduler
body: <p>I have a <code>.bat</code> file to start the Windows service. When I run it manually it works fine but if I run it from task scheduler it gives the following error.</p>
  
  <pre><code>'psexec64.exe' is not recognized as an internal or external command,
  operable program or batch file.
  The system cannot find the file sessid.txt.
  Press any key to continue . . .
  </code></pre>
  
  <p>I tried with the following scenarios</p>
  
  <ul>
  <li>Tried with both <code>psexec64.exe</code> and <code>psexec.exe</code></li>
  <li>Added the <code>psexec</code> path in environment variables</li>
  </ul>
  
  <p>still no luck</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  
  set username=user1
  set usr=bdomain\user1
  set password=2018
  set machine=192.168.1.16
  
  psexec64.exe \\%machine% -u %usr% -p %password% query session %username%&gt;D:\Service_Start\sessid.txt
  
  set /a counter=0
  for /F "tokens=* skip=1" %%a in (sessid.txt) do (
      for %%b in (%%a) do (
          set /a counter+=1
          if !counter! == 3 (
              psexec64.exe \\192.168.1.16 -u bdomain\user1 -p 2018 -i %%b -d net start OracleServiceTest
          )
      )
  )
  pause;
  </code></pre>