title: how to assign device id (COMn or LTPn) in a variable in batch script
body: <p>The <code>device ID</code> for printer I am getting and assigning it to a variable <code>printerPort</code></p>
  
  <pre class="lang-bat prettyprint-override"><code>for /f "tokens=* skip=1" %%a in ('wmic path Win32_SerialPort get DeviceID') do set printerPort=%%a
  
  echo %printerPort%
  </code></pre>
  
  <p>Output :</p>
  
  <pre><code>set printerPort=COM1
  set printerPort=
  echo
  </code></pre>
  
  <p>How to get device Id <strong>COM1</strong> in variable <code>printerPort</code>?</p>