1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/toggle_if.vbs Thu Jan 21 07:19:45 2010 +0900
1.3 @@ -0,0 +1,53 @@
1.4 +if WScript.Arguments.Count <> 2 then
1.5 + wscript.quit
1.6 +end if
1.7 +
1.8 +Dim sConnectionName
1.9 +if WScript.Arguments.Item(0) = "lan" then
1.10 + sConnectionName = "ローカル エリア接続"
1.11 +else
1.12 + sConnectionName = "ワイヤレス ネットワーク接続"
1.13 +end if
1.14 +
1.15 +Dim sVerb
1.16 +if WScript.Arguments.Item(1) = "enable" then
1.17 + sVerb = "有効にする(&A)"
1.18 +else
1.19 + sVerb = "無効にする(&B)"
1.20 +end if
1.21 +
1.22 +
1.23 +Const ssfCONTROLS = 3
1.24 +Const sConPaneName = "ネットワーク接続"
1.25 +
1.26 +set shellApp = createobject("shell.application")
1.27 +set oControlPanel = shellApp.Namespace(ssfCONTROLS)
1.28 +set oNetConnections = nothing
1.29 +
1.30 +for each folderitem in oControlPanel.items
1.31 + if folderitem.name = sConPaneName then
1.32 + set oNetConnections = folderitem.getfolder: exit for
1.33 + end if
1.34 +next
1.35 +
1.36 +if oNetConnections is nothing then
1.37 + wscript.quit
1.38 +end if
1.39 +
1.40 +set oLanConnection = nothing
1.41 +for each folderitem in oNetConnections.items
1.42 + if lcase(folderitem.name) = lcase(sConnectionName) then
1.43 + set oLanConnection = folderitem: exit for
1.44 + end if
1.45 +next
1.46 +
1.47 +if oLanConnection is nothing then
1.48 + wscript.quit
1.49 +end if
1.50 +
1.51 +for each verb in oLanConnection.verbs
1.52 + if verb.name = sVerb then
1.53 + verb.Doit
1.54 + WScript.Sleep 2000
1.55 + end if
1.56 +next