Extracting Network Profiles and displaying only Network Profile description in txt file

前端 未结 2 769
栀梦
栀梦 2021-01-15 17:37

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

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-15 18:03

    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
    

提交回复
热议问题