Add scripts to set network if.
authorShingo W. Kagami
Thu, 21 Jan 2010 07:19:45 +0900
changeset 376409631fed5
parent 2 5ba7dd492647
child 4 1b55a5510213
Add scripts to set network if.
lan_dhcp.bat
lan_ic.bat
toggle_if.vbs
wireless_dhcp.bat
wireless_ic.bat
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lan_dhcp.bat	Thu Jan 21 07:19:45 2010 +0900
     1.3 @@ -0,0 +1,5 @@
     1.4 +wscript C:\cygwin\home\swk\bin\toggle_if.vbs wireless disable
     1.5 +wscript C:\cygwin\home\swk\bin\toggle_if.vbs lan enable
     1.6 +netsh interface ip set address "ローカル エリア接続" dhcp
     1.7 +netsh interface ip set dns "ローカル エリア接続" dhcp
     1.8 +netsh interface ip set wins "ローカル エリア接続" dhcp
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lan_ic.bat	Thu Jan 21 07:19:45 2010 +0900
     2.3 @@ -0,0 +1,5 @@
     2.4 +wscript C:\cygwin\home\swk\bin\toggle_if.vbs wireless disable
     2.5 +wscript C:\cygwin\home\swk\bin\toggle_if.vbs lan enable
     2.6 +netsh interface ip set address "ローカル エリア接続" static 10.240.10.207 255.255.255.0 10.240.10.1 1
     2.7 +netsh interface ip set dns "ローカル エリア接続" static 130.34.54.2
     2.8 +netsh interface ip add dns "ローカル エリア接続" 130.34.232.25
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/toggle_if.vbs	Thu Jan 21 07:19:45 2010 +0900
     3.3 @@ -0,0 +1,53 @@
     3.4 +if WScript.Arguments.Count <> 2 then
     3.5 +        wscript.quit
     3.6 +end if
     3.7 +
     3.8 +Dim sConnectionName
     3.9 +if WScript.Arguments.Item(0) = "lan" then
    3.10 +        sConnectionName = "ローカル エリア接続" 
    3.11 +else
    3.12 +        sConnectionName = "ワイヤレス ネットワーク接続" 
    3.13 +end if
    3.14 +
    3.15 +Dim sVerb
    3.16 +if WScript.Arguments.Item(1) = "enable" then
    3.17 +        sVerb = "有効にする(&A)" 
    3.18 +else
    3.19 +        sVerb = "無効にする(&B)" 
    3.20 +end if
    3.21 +
    3.22 +
    3.23 +Const ssfCONTROLS = 3 
    3.24 +Const sConPaneName = "ネットワーク接続" 
    3.25 +
    3.26 +set shellApp = createobject("shell.application") 
    3.27 +set oControlPanel = shellApp.Namespace(ssfCONTROLS) 
    3.28 +set oNetConnections = nothing 
    3.29 +
    3.30 +for each folderitem in oControlPanel.items 
    3.31 +	if folderitem.name = sConPaneName then 
    3.32 +		set oNetConnections = folderitem.getfolder: exit for 
    3.33 +	end if 
    3.34 +next 
    3.35 +
    3.36 +if oNetConnections is nothing then 
    3.37 +	wscript.quit 
    3.38 +end if 
    3.39 +
    3.40 +set oLanConnection = nothing 
    3.41 +for each folderitem in oNetConnections.items 
    3.42 +	if lcase(folderitem.name) = lcase(sConnectionName) then 
    3.43 +		set oLanConnection = folderitem: exit for 
    3.44 +	end if 
    3.45 +next 
    3.46 +
    3.47 +if oLanConnection is nothing then 
    3.48 +	wscript.quit 
    3.49 +end if 
    3.50 +
    3.51 +for each verb in oLanConnection.verbs 
    3.52 +	if verb.name = sVerb then 
    3.53 +		verb.Doit 
    3.54 +		WScript.Sleep 2000 
    3.55 +	end if 
    3.56 +next 
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/wireless_dhcp.bat	Thu Jan 21 07:19:45 2010 +0900
     4.3 @@ -0,0 +1,5 @@
     4.4 +wscript C:\cygwin\home\swk\bin\toggle_if.vbs lan disable
     4.5 +wscript C:\cygwin\home\swk\bin\toggle_if.vbs wireless enable
     4.6 +netsh interface ip set address "ワイヤレス ネットワーク接続" dhcp
     4.7 +netsh interface ip set dns "ワイヤレス ネットワーク接続" dhcp
     4.8 +netsh interface ip set wins "ワイヤレス ネットワーク接続" dhcp
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/wireless_ic.bat	Thu Jan 21 07:19:45 2010 +0900
     5.3 @@ -0,0 +1,5 @@
     5.4 +wscript C:\cygwin\home\swk\bin\toggle_if.vbs lan disable
     5.5 +wscript C:\cygwin\home\swk\bin\toggle_if.vbs wireless enable
     5.6 +netsh interface ip set address "ワイヤレス ネットワーク接続" static 10.240.10.207 255.255.255.0 10.240.10.1 1
     5.7 +netsh interface ip set dns "ワイヤレス ネットワーク接続" static 130.34.54.2
     5.8 +netsh interface ip add dns "ワイヤレス ネットワーク接続" 130.34.232.25