答案1
目前,最好的解决方案如下(参见@somebadhat 的评论):
Windows 7 版本本网站显示一个.vbs
脚本启用/禁用网络适配器。不幸的是,它最后需要管理员权限,并且会出现 UAC 提示。如果有更好的解决方案,请使用此内容编辑此社区 wiki。
因为我有一台德国电脑,所以我需要将其更改En&able
为&Aktivieren
并将Disa&ble
更改为&Deaktivieren
。您可以将其改回来。
另外,我将适配器名称更改为WLAN
。
我采用的脚本:
'~ Toggle a SPECIFIED NIC on or off
Option Explicit
Const NETWORK_CONNECTIONS = &H31&
Dim objShell, objFolder, objFolderItem, objEnable, objDisable, wshShell
Dim folder_Object, target_NIC
Dim NIC, clsVerb
Dim str_NIC_Name, strEnable, strDisable
Dim bEnabled, bDisabled
' ========================================================
' ===== place the name of your network adapter here ======
' examples:
' str_NIC_Name = "Local Area Connection 2"
' str_NIC_Name = "Wireless Connection 1"
' ========================================================
str_NIC_Name = "WLAN"
' ========================================================
strEnable = "&Aktivieren"
strDisable = "&Deaktivieren"
' create objects and get items
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)
Set objFolderItem = objFolder.Self
Set folder_Object = objFolderItem.GetFolder
' see if the namespace exists
If folder_Object Is Nothing Then
Wscript.Echo "Could not find Network Connections"
WScript.Quit
End If
Set target_NIC = Nothing
' look at each NIC and match to the chosen name
For Each NIC In folder_Object.Items
If LCase(NIC.Name) = LCase(str_NIC_Name) Then
' proper NIC is found, get it
Set target_NIC = NIC
End If
Next
If target_NIC Is Nothing Then
WScript.Echo "Unable to locate proper NIC"
WScript.Quit
End If
bEnabled = True
Set objEnable = Nothing
Set objDisable = Nothing
For Each clsVerb In target_NIC.Verbs
'~ Wscript.Echo clsVerb
If clsVerb.Name = strEnable Then
Set objEnable = clsVerb
bEnabled = False
'~ WScript.Echo "enable"
End If
If clsVerb.Name = strDisable Then
Set objDisable = clsVerb
'~ WScript.Echo "disable"
End If
Next
Set wshShell = CreateObject( "WScript.Shell" )
If bEnabled Then
WScript.Echo "disable"
objDisable.DoIt
Else
WScript.Echo "enable"
objEnable.DoIt
End If
wshShell.Run "ms-settings:network-proxy"
'~ Give the connection time to stop/start, prompt after UAC prompt
WScript.Sleep 1000
WScript.Echo "end"
WScript.Quit