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 usi
From this thread : Wi-Fi SSID detail
I don't know if this code works over english machines or not, because, i just tried it until now, on my french machine. so, just give a try and tell me the results :
@echo off & setlocal enabledelayedexpansion & color 0A
Title %~n0 to get SSID With details
::::::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights ::
::::::::::::::::::::::::::::::::::::::::::::
Set TmpLogFile=%tmp%\TmpLog.txt
If Exist %TmpLogFile% Del %TmpLogFile%
REM --> Check for permissions
Reg query "HKU\S-1-5-19\Environment" >%TmpLogFile% 2>&1
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
Echo.
ECHO ****************************************
ECHO ^| Running Admin shell... Please wait...^|
ECHO ****************************************
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::
Set "TmpLog=%~dp0%~n0_Tmp.txt"
Set "Log=%~dp0%~n0.txt"
If Exist "%TmpLog%" Del "%TmpLog%"
If Exist "%Log%" Del "%Log%"
rem Populate the array
Set i=0
for /f "skip=1 tokens=2 delims=:" %%a in ('netsh wlan show profiles ^|find /i "Profil"') do (
set /A i+=1
set "list[!i!]=%%a"
)
set SSID=%i%
rem Display array elements for SSID List
cls
for /L %%i in (1,1,%SSID%) do (
echo(
echo SSID number %%i: "!list[%%i]:~1!!"
echo(
)
pause
rem Display array elements for SSID List with details
cls
for /L %%i in (1,1,%SSID%) do (
echo(
echo SSID number %%i: "!list[%%i]:~1!!"
echo(
netsh wlan show profiles "!list[%%i]:~1!!" key=clear
netsh wlan show profiles "!list[%%i]:~1!!" key=clear >> "%TmpLog%"
)
Cmd /U /C Type "%TmpLog%" > "%Log%"
If Exist "%TmpLog%" Del "%TmpLog%"
Start "" "%Log%"
pause
exit /b
Here is an quick example which should output a file providing each GUID and Description alongside your running script.
@Echo Off
SetLocal EnableExtensions DisableDelayedExpansion
(Set k=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles)
For /F "Delims==" %%A In ('Set GUID[ 2^>Nul') Do Set "%%A="
Set "i=101"
For /F "EOL=E Tokens=1,2*" %%A In ('Reg Query "%k%" /S /V Description') Do (
If "%%~nB" NEq "%%~B" (Call Set "GUID[%%i:*1=%%]=%%~nB") Else (
Call Call Set GUID[%%i:*1=%%]="%%%%GUID[%%i:*1=%%]%%%%","%%C"
Set/A i+=1))
If %i% NEq 101 (>"%~dp0NetProfs.log" 2>Nul Set GUID[)
EndLocal
Exit/B
You will probably need to right-click and run as Administrator due to resrictions on those keys.