title: Use wmic to join domain and change computer name simultaneously
body: <p>I'm trying to create a AD setup script, and I need to change the hostname then join the domain.</p>
  <p>If I execute both of the following command, the domain will not be joined:</p>
  <pre><code>wmic computersystem where name='%computername%' call rename name='NEW_NAME'
  wmic computersystem where name=&quot;%computername%&quot; call joindomainorworkgroup fjoinoptions=3 name=&quot;XXX.com&quot; username=&quot;XXX\admin&quot; Password=&quot;XXXX&quot;
  </code></pre>
  <p>It works only if I execute them one by one. But in explorer user can configure both properties simultaneously.</p>
  <p>Any ideas?</p>