diff -r 3b65651e7033 -r 577963cc46fc net/toggle_if.vbs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/net/toggle_if.vbs Fri Jan 22 01:01:29 2010 +0900 @@ -0,0 +1,53 @@ +if WScript.Arguments.Count <> 2 then + wscript.quit +end if + +Dim sConnectionName +if WScript.Arguments.Item(0) = "lan" then + sConnectionName = "ローカル エリア接続" +else + sConnectionName = "ワイヤレス ネットワーク接続" +end if + +Dim sVerb +if WScript.Arguments.Item(1) = "enable" then + sVerb = "有効にする(&A)" +else + sVerb = "無効にする(&B)" +end if + + +Const ssfCONTROLS = 3 +Const sConPaneName = "ネットワーク接続" + +set shellApp = createobject("shell.application") +set oControlPanel = shellApp.Namespace(ssfCONTROLS) +set oNetConnections = nothing + +for each folderitem in oControlPanel.items + if folderitem.name = sConPaneName then + set oNetConnections = folderitem.getfolder: exit for + end if +next + +if oNetConnections is nothing then + wscript.quit +end if + +set oLanConnection = nothing +for each folderitem in oNetConnections.items + if lcase(folderitem.name) = lcase(sConnectionName) then + set oLanConnection = folderitem: exit for + end if +next + +if oLanConnection is nothing then + wscript.quit +end if + +for each verb in oLanConnection.verbs + if verb.name = sVerb then + verb.Doit + WScript.Sleep 2000 + end if +next