0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

無線プロファイル用ばっちっち。

Posted at
wlan_profiles.cmd
@echo off
setlocal
%~d0
cd %~p0
:loop
echo.
echo   1. 既知の無線プロファイルを '%CD%'XMLファイルとして保存します。
echo   2. 無線プロファイルを '%CD%' に有る全ての XMLファイルから追加します。
echo   3. すべてのインターフェイスから、すべてのワイヤレス ネットワーク プロファイルを削除します。
echo   4. 指定したワイヤレス ネットワーク プロファイルを最優先へ設定します。
echo   5. ヤメル!?
::echo.
::echo   1. Export wifi profiles to '%CD%' as an XML file.
::echo   2. Import wifi profiles from all XML files in '%CD%'.
::echo   3. Remove all wireless network profiles from all interfaces.
::echo   4. Set a specifies wireless network profile to top of the preference order.
::echo   5. Abort!?
echo.
set made=
set /p mode="> "
if "%mode%"=="1" (
    for /f "tokens=2 delims=:" %%A in ('netsh wlan show profiles') do (
        call :export %%A
    )
    goto :end
)
if "%mode%"=="2" (
    for %%A in (*.xml) do netsh wlan add profile filename="%%A"
    goto :end
)
if "%mode%"=="3" (
    for /f "tokens=2 delims=:" %%A in ('netsh wlan show profiles') do (
        call :delete %%A
    )
    goto :end
)
if "%mode%"=="4" (
    goto :priority
)
if not "%mode%"=="5" goto :loop
:end
endlocal
pause
exit
:delete
set name=%*
if defined name netsh wlan delete profile name="%name%" i=*
exit /b
:export
set name=%*
if defined name netsh wlan export profile name="%name%" folder=. key=clear
exit /b
:priority
echo.
:loop2
for /f "tokens=2 delims=:" %%A in ('netsh wlan show profiles') do (
    call :choices %%A
)
echo.
set n=
set q=a
set /p q="Which do you prefer [%choices:~0,-1%]?"
goto :loop2
:choices
set name=%*
if defined name (set /a n=n+1) else (exit /b)
if not defined q (
    set choices=%choices%%n%,
    echo   %n%. %name%
) else if "%q%"=="1" (
    set q=a
    echo.
    echo It's already top priority.
) else if "%n%"=="%q%" (
    netsh wlan set profileorder name="%name%" interface="Wi-Fi" priority=1
    goto :end
)
exit /b
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?