I am very new to batch scripting and have to use console to interrogate Registry for network profile description and output only the description data to a txt file. I am using a for /f loop to do this. I first reg query the whole key so it lists every sub key for network profiles and stores this in a text document. I then for /f this text file to extract out only the subkey name using tokens to store this as a variable. I then use the variable to reg query the individual keys for the Description name and output this to another text file which should display only the Network profile description. Below is my batch script.
Echo Required to skip line for processing >>%~dp0\1SSID.txt
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles" /s /v Description >>%~dp0\1SSID.txt
setlocal enableDelayedExpansion
rem get each key from 1SSID.txt
for /f "usebackq skip=1 tokens=1,2" %%i in ("%~dp0\1SSID.txt") do (
echo %%i %%j>>%~dp0\2Processingstage.txt
rem skip the first line and grab tokens 3 from the second line to show description and desription name
for /f "usebackq skip=1 tokens=3" %%k in (`reg query "%%I %%j" /v Description`) do set "Description=%%l
echo Network Description - %%l >>%~dp0\3SSIDoutput.txt
)
)
The first think I notice is the skip=1 doesn't work and look at every line. As this doesn't work it doesn't extract the correct data to place into the reg query. I have tried with different tokens, without skip, with skip, with delims (which it didn't recognise). Ive been working on this for hours and simply cant get it to work. This is probably simple but I cant find a way around this.