(ZT) 와이파이 핫스팟 설정 bat 스크립트

23070 단어
전언
인터넷에서 bat 스크립트와 ics를 찾았어요.vbs 만약 컴퓨터에 무선랜카드가 있다면 아래의 스크립트로 와이파이 핫이슈를 설정할 수 있습니다.내 데스크톱에는 무선랜카드가 없어서 아래의 스크립트를 시험할 방법이 없다.나중에 기회가 되면 다시 시험해 보자.
각본
@echo off & setlocal EnableDelayedExpansion
color 0e & title Win7           
rem             hot_wifi.bat
rem    0.2 Beta
(
set "ismode="   &rem           
set "isstart="  &rem           
set "isap=" &rem     ap  
set "apssid="   &rem      ssid
set "apmac="    &rem          
set "apip=" &rem      IP  
set "sumclient="    &rem              
set "clientip="     &rem    ip
set "clientmac="    &rem    mac
set "clientstate="  &rem        
set "ipclass="      &rem    ip  
set "n="        &rem     
)

:Begin
cls
echorem           
for /f "skip=3 tokens=2 usebackq delims=:" %%i in (`netsh wlan show hostednetwork`) do (
    if "!ismode!"=="" (
        if "%%i"=="    " (set "ismode=true") else (set "ismode=false")
        if "%%i"=="" (echo         :   ) else echo%%i
    )
)

rem           
for /f "skip=11 tokens=2 usebackq delims=:" %%i in (`netsh wlan show hostednetwork`) do (
    if "!isstart!"=="" (
        if "%%i"=="    " (set "isstart=true") else (set "isstart=false")
        if "%%i"=="" (echo         :   ) else echo%%i
    )
)

rem        SSID、MAC、IP
if /i "!isstart!"=="true" (
    for /f "skip=4 tokens=1* usebackq delims=:" %%i in (`netsh wlan show hostednetwork`) do if "!apssid!"=="" set "apssid=%%j"
    echo        SSID:!apssid!
    for /f "skip=12 tokens=1* usebackq delims=:" %%i in (`netsh wlan show hostednetwork`) do if "!apmac!"=="" set "apmac=%%j"
    set "apmac=!apmac::=-!" &rem  :   -
    echo!apmac!
    for /f "tokens=1* usebackq delims=:" %%i in (`ipconfig /all`) do (
        if /i "%%j"==" !apmac!" set "isap=true" &rem    ap  
        if /i "!isap!"=="true" (
            set "n=%%i"
            if /i "!n:~0,7!"=="   IPv4" (
                set "apip=%%j"
                set "isap=false" &rem    ap  
            )
        )
    )
    for /f "delims=(" %%i in ("!apip!") do set "apip=%%i" &rem    ip  
    echo        IP  :!apip!
) else echo          ,SSID    & echo          ,IP        
echo - - - - - -
echo;

if /i not "!isstart!"=="true" (echo        ,        ) else (
    echorem        
    for /f "skip=15 tokens=2 usebackq delims=:" %%i in (`netsh wlan show hostednetwork`) do (
        if "!sumclient!"=="" (
            set "sumclient=%%i"
            echo!sumclient!
        )
    )
    if !sumclient! gtr 0 (
        echo                                        IP  
        set "n=1"
        for /f "skip=16 tokens=1,2 usebackq delims= " %%i in (`netsh wlan show hostednetwork`) do (
            set "clientmac=%%i"
            set "clientmac=!clientmac::=-!" &rem  :   -
            set "clientstate=%%j"
            for /f "tokens=1,3 usebackq delims= " %%l in (`arp -a -n %apip% ^| find /i "!clientmac!"`) do (
                set "clientip=%%l"
                set "ipclass=%%m"
            )
            echo   !n!  !ipclass!   !clientstate!       !clientmac!   !clientip!
            set /a n+=1
        )
    ) else echo                  
)   

echo - - - - - -
:return
@echo off
@echo ___________________________________
@echo +++++++++++    ++++++++++++++++
@echo +   1.                      +
@echo +   2.                      +
@echo +   3.  SSID KEY               +
@echo +   4.    KEY                 +
@echo +   5.                      +
@echo +   6.       WIFI          +
@echo +++++++++++++++++++++++++++++++++++
set /p choice=     
if %choice%==1 goto a
if %choice%==2 goto b
if %choice%==3 goto c
if %choice%==4 goto d
if %choice%==5 goto Begin
if %choice%==6 goto exit

cls
@echo -_-。sorry!    ,       !
goto return

:a
netsh wlan stop hostednetwork
cscript /nologo ics.vbs "!apssid!" "      " "off"
cscript /nologo ics.vbs "!apssid!" "    " "on"
netsh wlan start hostednetwork
goto :end

:b
netsh wlan stop hostednetwork
cscript /nologo ics.vbs "!apssid!" "    " "off"
cscript /nologo ics.vbs "!apssid!" "      " "on"
netsh wlan start hostednetwork
goto :end 

:c
@echo
@echo   :  Windows 7           
@echo             Windows!!!
@echo       Windows 7    
@echo              (ssid)        (key)!!!
@pause
@echo off
echo       SSID   KEY
echo           SSID(Enter  ): 
set/p SSID=
echo      KEY(     88      ,Enter  ):
set/p Password=
netsh wlan set hostednetwork mode=allow ssid=%SSID% key=%Password%
netsh wlan start hostednetwork
@echo ……OK!
cls
goto return

:d
@echo   :             (KEY)!!!
@echo off
echo       (      88      ,Enter  ):
:PW2 set/p Password=
netsh wlan set hostednetwork mode=allow key=%Password%
netsh wlan start hostednetwork
cls
goto return

:end
rem cls
goto return
pause

:exit
cls
netsh wlan stop hostednetwork
@echo 3        
ping /n 1 /w 3000 1.0.0.1>nul 
exit

rem
(
pause
set "apn=%%i"
set /p choice=  
if %choice%==Y goto l
if %choice%==y goto l
if %choice%==Y goto m
if %choice%==n goto m
for /f "usebackq tokens=2 delims= " %%i in (`ipconfig /all^|find "        "`) do (
    echo %%i
    pause
    netsh interface set interface name=!apn! newname=    2
    )
)


vbs
' filename ics.vbs
'Originally from http://www.autoitscript.com/forum/topic/28897-switch-ics/
'Changed to VBS, added arguments and fixed for private/public networkds by Dror Gluska 2012-06-25
'Dror Gluska (2012) - http://uhurumkate.blogspot.co.il/


option explicit



Main( )

sub Main( )
    dim objArgs, con, endis,con2

    Set objArgs = WScript.Arguments

    'WScript.Echo objArgs.Count

    if objArgs.Count > 0 then
        con = objArgs(0)
        con2 = objArgs(1)
        endis = objArgs(2)

        EnableDisableICS con,con2, endis  'true enables, false disables

    else
        DIM szMsg
        szMsg = "Invalid usage! Please provide the name of the connection as the argument." & vbCRLF & vbCRLF & _
                "Usage:" & vbCRLF & _ 
                "       " + WScript.scriptname + " ""Public Connection Name"" ""Private Connection Name"" true/false"
        WScript.Echo( szMsg )  

    end if

end sub



function EnableDisableICS(sPublicConnectionName, sPrivateConnectionName, bEnable)

    dim  bFound
    bFound = FALSE
    dim oNetSharingManager, oConnectionCollection, oItem, EveryConnection, objNCProps

    set oNetSharingManager = Wscript.CreateObject("HNetCfg.HNetShare.1")
     if (IsObject(oNetSharingManager)) = FALSE then
        Wscript.Echo("Unable to get the HNetCfg.HnetShare.1 object.")
        Exit function
    End if

    if (IsNull(oNetSharingManager.SharingInstalled) = TRUE) then
        Wscript.Echo( "Sharing is not available on this platform.")
        Exit function
    End if



     set oConnectionCollection = oNetSharingManager.EnumEveryConnection
    for each oItem In oConnectionCollection
        set EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection (oItem)
        set objNCProps = oNetSharingManager.NetConnectionProps (oItem)
         If  objNCProps.name = sPrivateConnectionName Then
            bFound = True
           Wscript.Echo("Setting ICS Private to " & bEnable & " on connection: " & objNCProps.name)
            If bEnable Then
                EveryConnection.EnableSharing (1)
            Else
                EveryConnection.DisableSharing
            End if
        End if
    Next

    set oConnectionCollection = oNetSharingManager.EnumEveryConnection
    for each oItem In oConnectionCollection
        set EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection (oItem)
        set objNCProps = oNetSharingManager.NetConnectionProps (oItem)

        If  objNCProps.name = sPublicConnectionName Then
            bFound = True
           Wscript.Echo("Setting ICS Public to " & bEnable & " on connection: " & objNCProps.name)
            If bEnable Then
                EveryConnection.EnableSharing (0)
            Else
                EveryConnection.DisableSharing
            End if
        End if
    next

    If Not bFound Then
       Wscript.Echo("Unable to find the connection " & sPublicConnectionName)
    End if

end function

좋은 웹페이지 즐겨찾기