title: Save a specific field from output into a variable on windows CMD
body: <p>I want to read the wlan-key from <code>netsh wlan show hostednetwork setting=security</code> and save it in a variable so i can display it without the unneeded information like..:</p>
  
  <pre><code>echo your key is %wlan_key%
  </code></pre>
  
  <p>I already googled the problem on my own and found a <a href="https://stackoverflow.com/questions/5898763/how-do-i-get-the-ip-address-into-a-batch-file-variable">similar topic</a>. I used the approach from <a href="https://stackoverflow.com/a/14007404">James A Mohler</a> and tried to adapt it to my problem but it doesn't worked.
  failed attempt:</p>
  
  <pre><code>for /f "tokens=1-2 delims=:" %%a in ('netsh wlan show hostednetwork setting=security^|find "  Benutzer"') do set key=%%b
  set key=%key:~1%
  echo %key%
  pause
  </code></pre>