title: WMIC commands to change computer name to BIOS serial number
body: <p>I'm new with batch file and wmic and after researching StackOverflow I've found few answers which overlap but not producing expected output when put together.</p>
  
  <p>Problem:</p>
  
  <p>Create a batch file to change computer name (not on domain):</p>
  
  <ol>
  <li>use <code>wmic bios get serialnumber</code> and assign the value to the variable <code>comp_name</code>, then display the value of this variable;</li>
  <li>change computer name to the value of the variable <code>comp_name</code>;</li>
  </ol>
  
  <p>So for 1.:</p>
  
  <pre><code>FOR /F %%F IN ('wmic bios get serialnumber') DO (
  SET comp_name=%%F
  )
  ECHO %comp_name%
  </code></pre>
  
  <p>Followed by 2.:</p>
  
  <pre><code>WMIC computersystem where name="%computername%" rename name=%%comp_name%%
  </code></pre>
  
  <p>edit: got a 1. part correct - works as expected - fetching serial number and displays the variable's value. However part 2. still throwing errors:</p>
  
  <pre><code>O:\&gt;wmic computersystem where name="TOM-PC" rename NAME=
  Invalid named parameter list.
  Hint: &lt;named param list&gt; ::= &lt;named param&gt; | &lt;named param&gt; &lt;named param list&gt; where &lt;named param&gt; ::= &lt;param name&gt;=&lt;param value&gt;
  </code></pre>
  
  <p>If I understand correctly - the <code>NAME=...</code> part of the last command don't recognise variable initialised above. So how to use a <code>comp_name</code> as a parameter for <code>wmic</code> command?</p>
  
  <p>edit .2 </p>
  
  <p>"Why are you using doubled % signs in name=%%comp_name%%?" by <code>aschipfl</code> - I reverted to my original question - used double <code>%</code> and now getting different error - 87 which tells me more about the problem. using singles <code>%</code> produce the error listed above. I'm not sure if the problems lies in single or doubles<code>%</code> or somewhere else.</p>
  
  <p>edit .3</p>
  
  <p>Further research shows that <code>wmic bios get serialnumber</code> returns in fact three values each in new line </p>
  
  <pre><code>C:\Windows\system32&gt;wmic bios get serialnumber
  SerialNumber
  BY3VF02
  </code></pre>
  
  <p>that is - <code>SerialNumber</code> string followed by actual serial number in new line and last one with just empty line. So (I hope) the final questions - how to assign only the second value to my variable please?</p>