title: Sending a command to a range of IP's using PSEXEC and a Batch file
body: <p>I'm trying to send an unlock command to remote computers.  All computers are on the same subnet and an upper and lower IP will be provided at run time.</p>
  
  <p>I have constructed the following:</p>
  
  <pre><code>:range
  echo.
  set /a ip=xxx.xxx.xxx
  echo Please input lower IP range.
  set /p lower=%ip%
  echo.
  echo Please input upper IP range.
  set /p upper=%ip%
  set /a lip=
  echo.
  
  
  :loop
  set lip = %ip%%lower%
  psexec \\%lip% -u .\&lt;redacted&gt; -p &lt;redacted&gt; Net user &lt;redacted&gt; /Active:yes
  if %lower%==%upper% goto loopend
  set /a lower=%lower%+1
  goto loop
  
  :loopend
  goto end
  </code></pre>
  
  <p>This gives me a lot of errors.  Firstly, I understood <code>set lip = %ip%%lower%</code> would concatenate the two.  I'm not certain they are being processed as strings, however.  How can this be resolved?</p>
  
  <p>If I echo <code>%ip%</code> I only see the first part of the IP (before the first .).  Clearly this data isn't being stored correctly.  I tried enclosing it in speech marks with no success (it says Missing operator).</p>
  
  <p>I am open to any radically different solutions if you feel I am making a pigs ear of this.</p>