Save a specific field from output into a variable on windows CMD

Viewed 599

I want to read the wlan-key from netsh wlan show hostednetwork setting=security and save it in a variable so i can display it without the unneeded information like..:

echo your key is %wlan_key%

I already googled the problem on my own and found a similar topic. I used the approach from James A Mohler and tried to adapt it to my problem but it doesn't worked. failed attempt:

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
1 Answers
Related