Created
June 24, 2009 06:20
-
-
Save tckz/135047 to your computer and use it in GitHub Desktop.
ifdown/up for windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sh = New-Object -ComObject Shell.Application | |
$nc = $sh.NameSpace(3).Items() | ? { $_.Name -eq "ネットワーク接続" } | |
$lan = $nc.GetFolder.Items() | ? { $_.Name -eq "ローカル エリア接続" } | |
$disable = $lan.Verbs() | ? { $_.Name -eq "無効にする(&B)" } | |
if($disable) | |
{ | |
write-host "disabling." | |
$disable.DoIt() | |
} | |
# disable後少し待たないとメソッドが現れない | |
$enable = $null | |
while($enable -eq $null) | |
{ | |
write-host "Waiting to be available." | |
$enable = $lan.Verbs() | ? { $_.Name -eq "有効にする(&A)" } | |
} | |
$enable.DoIt() | |
sleep 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment