toggle_if.vbs
author Shingo W. Kagami
Thu, 21 Jan 2010 14:04:22 +0900
changeset 4 1b55a5510213
permissions -rw-r--r--
Batch files dualdisp_*.bat have been removed (and replaced by zsh aliases).
Shingo@3
     1
if WScript.Arguments.Count <> 2 then
Shingo@3
     2
        wscript.quit
Shingo@3
     3
end if
Shingo@3
     4
Shingo@3
     5
Dim sConnectionName
Shingo@3
     6
if WScript.Arguments.Item(0) = "lan" then
Shingo@3
     7
        sConnectionName = "ローカル エリア接続" 
Shingo@3
     8
else
Shingo@3
     9
        sConnectionName = "ワイヤレス ネットワーク接続" 
Shingo@3
    10
end if
Shingo@3
    11
Shingo@3
    12
Dim sVerb
Shingo@3
    13
if WScript.Arguments.Item(1) = "enable" then
Shingo@3
    14
        sVerb = "有効にする(&A)" 
Shingo@3
    15
else
Shingo@3
    16
        sVerb = "無効にする(&B)" 
Shingo@3
    17
end if
Shingo@3
    18
Shingo@3
    19
Shingo@3
    20
Const ssfCONTROLS = 3 
Shingo@3
    21
Const sConPaneName = "ネットワーク接続" 
Shingo@3
    22
Shingo@3
    23
set shellApp = createobject("shell.application") 
Shingo@3
    24
set oControlPanel = shellApp.Namespace(ssfCONTROLS) 
Shingo@3
    25
set oNetConnections = nothing 
Shingo@3
    26
Shingo@3
    27
for each folderitem in oControlPanel.items 
Shingo@3
    28
	if folderitem.name = sConPaneName then 
Shingo@3
    29
		set oNetConnections = folderitem.getfolder: exit for 
Shingo@3
    30
	end if 
Shingo@3
    31
next 
Shingo@3
    32
Shingo@3
    33
if oNetConnections is nothing then 
Shingo@3
    34
	wscript.quit 
Shingo@3
    35
end if 
Shingo@3
    36
Shingo@3
    37
set oLanConnection = nothing 
Shingo@3
    38
for each folderitem in oNetConnections.items 
Shingo@3
    39
	if lcase(folderitem.name) = lcase(sConnectionName) then 
Shingo@3
    40
		set oLanConnection = folderitem: exit for 
Shingo@3
    41
	end if 
Shingo@3
    42
next 
Shingo@3
    43
Shingo@3
    44
if oLanConnection is nothing then 
Shingo@3
    45
	wscript.quit 
Shingo@3
    46
end if 
Shingo@3
    47
Shingo@3
    48
for each verb in oLanConnection.verbs 
Shingo@3
    49
	if verb.name = sVerb then 
Shingo@3
    50
		verb.Doit 
Shingo@3
    51
		WScript.Sleep 2000 
Shingo@3
    52
	end if 
Shingo@3
    53
next