title: Running multiple for loops in batch
body: <p>I wrote a code that connects to 70 or more windows servers (list in sis.txt), identifies which is the correct certificate and copies it to the server. The filename of the certicate is "hostname.pfx", which is same as the output command of "hostname" + .pfx
  The problem is, that I can use %%i only one time in this code. Currently, it will not run the 3rd line at all, or atleast will not save it's output into a variable called %filename%, because %%i is already allocated to something else. I also tried %%g but no joy. I wan't the output of 3rd line to be saved into a variable which I can then use in the 6th line (xcopy command). Since the output of hostname command would be the actual hostname (server1-global) then it would pick the correct certificate file (server1-global.pfx) to copy.
  I know that this is probably an ass-backwards method, but it is the best I could come up with given that batch syntax and logic make my head hurt and nearly vomit.</p>
  
  <pre><code>FOR /F %%i IN (sis.txt) DO(
  ECHO %%i
  FOR /F %%i in ('PsExec.exe \\%%i -u myuser -p mypassword cmd /c hostname') do set filename=%%i
  ECHO %filename%
  START /Wait NET USE S: \\%%i\c$\transfer /USER:myuser mypassword
  xcopy U:\files\%filename%.pfx /e /k /Y S:\
  NET USE S: /Delete /Y
  )
  </code></pre>