title: Windows XP batch command schtasks doesnt' run a remote script
body: <p>I'm trying to create a <code>batch</code> file in order to run automatic scripts on several remote PCs.<br>
  My main machine should be able to connect to any remote PCs and set a local scheduled task.<br>
  The batch file uses these commands:</p>
  
  <pre><code>schtasks /delete               &lt;--- remove any previous version
           /S \\10.1.2.3         &lt;--- the remote PC's IP
           /U theAdministrator   &lt;--- the username to access the PC
           /P MyPassword         &lt;--- the password to access the PC
           /TN MyTask            &lt;--- task name
           /F                    &lt;--- don't ask, just do it option
  
  schtasks /create 
           /S \\10.1.2.3 
           /U theAdministrator 
           /P MyPassword 
           /RU theAdministrator  &lt;--- the username to execute the task 
           /RP MyPassword        &lt;--- the password to execute the task
           /SC dayly /MO 1       &lt;--- run every day
           /TN MyTask 
           /TR C:\task.bat       &lt;--- the script to run on the remote PC
  </code></pre>
  
  <p>When I launch the first <code>/delete</code> command everything works, but the second returns a warning:<br>
  <em>"task has been created but probably it will not run because it hasn't been possible to set the account information"</em> <br> (I'm sorry if this is not the exact error message but I have to translate it by myself)</p>
  
  <p>I'm sure that username and password are correct because the <code>/delete</code> command is OK, and also <code>/create</code> one creates the task, even if it doesn't run.</p>
  
  <p>Therefore the problem should be with <code>/RU</code> and <code>/RP</code> options... </p>
  
  <hr>
  
  <p><strong>Solution:</strong></p>
  
  <p>I wasn't able to execute the command itself without this error message, anyway I've reached my aim and found two different options:</p>
  
  <p><em><strong>The simplest way using the AT command:</em></strong></p>
  
  <pre><code>AT \\10.1.2.3 12:00 C:\task.bat
  </code></pre>
  
  <p>It has no problem but needs to have specified an hour to run; this means if you want the task to be executed immediately you'll have to chatch <code>%time%</code> variable.<br>
  This option also doesn't allow to set an user to run the task (I've tested it as Administrator and the task was set to execute as <code>NT AUTHORITY/SYSTEM</code>) </p>
  
  <p><em><strong>The full featured way using PsTools:</em></strong><br>
  Passing the <code>schtasks /create</code> command to <code>PsExec</code></p>
  
  <pre><code>set command=schtasks /create /SC dayly /MO 1 /TN MyTask /TR C:\task.bat /RU theAdministrator /RP MyPassword
  PsExec \\10.1.2.3 -u theAdministrator -p MyPassword %command%
  </code></pre>
  
  <p><em><strong>NB.</em></strong> 
  The target <em>IP</em>, <em>user</em> and <em>password</em> to access the remote PC have to be set within <code>PsExec</code> command, therefore you don't need them on <code>schtasks</code>.<br> 
  The script task.bat already exists on root C:\ of the target PC.</p>