title: for loop with array in batch file with replacing a string variable
body: <p>I am trying to create a batch file to copy the file over network.</p>
  
  <p>first i am mapping the drive using <code>NET</code>command and than copy file using <code>xcopy</code>.</p>
  
  <p>follwing batch file works without any problem</p>
  
  <pre><code>    net use T: \\192.168.170.239\D /user:User1 PASSWROD
      set source=T:\backup
      set destination=D:\backup\
      xcopy %source% %destination% /y
      net use T: /delete 
      TIMEOUT 5
  </code></pre>
  
  <p>I would like to replace the static IP <code>'192.168.170.239'</code> and make any array of ip as below and replace the <code>netuse</code> command  in a loop.</p>
  
  <pre><code>@echo off 
  set obj[0]=192.168.170.239
  set obj[1]=192.168.170.240
  set obj[2]=192.168.170.241
  set obj[3]=192.168.170.242
  </code></pre>
  
  <p>I have treid the following but didn't work</p>
  
  <pre><code> @echo off
  set len=2
  set obj[0]=192.168.170.239
  set obj[1]=192.168.170.240
  
  
  set i=0
  :loop
  if %i% equ %len% goto :eof
  for /f "usebackq delims== tokens=2" %%j in (`set obj[%i%]`) do (
  
  net use T: \\%%j\D /user:User1 Password
  TIMEOUT 10
  set source=T:\Autobackup
  set destination=D:\Autobackup\
  xcopy %source% %destination% /y
  net use T: /delete 
  TIMEOUT 10
  
  )
  set /a i=%i%+1
  goto loop
  </code></pre>
  
  <p>It works for the second ip but not for the first ip.</p>