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