答案1
这应该会启动故障排除程序:
msdt.exe -id NetworkDiagnosticsNetworkAdapter
但它仍然需要知道其他东西(例如,如果您有多个适配器,哪一个需要故障排除)。了解您希望解决哪种问题会有所帮助,flushdns?禁用/重新启用某个适配器?要禁用和重新启用适配器,请使用以下命令找到您的适配器名称:
netsh interface show interface
查看接口名称列,使用该名称:
netsh interface set interface "YOUR-ADAPTER-NAME" disable
netsh interface set interface "YOUR-ADAPTER-NAME" enable
答案2
Windows 10 64 位
使用批处理文件禁用/启用名为 ethernet 的网络接口。必须以管理员权限运行。它的作用与使用设备管理器禁用/启用网络适配器相同。当您对它的工作感到满意时,注释/删除您不需要的行。
@rem Disable / enable your network interface named ethernet. Must be run with admin privileges. Windows 10 64-bit.
netsh interface set interface ethernet admin=disable
netsh interface show interface
echo sleep 1
timeout 1 > nul
netsh interface set interface ethernet admin=enable
netsh interface show interface
使用 Visual Basic 脚本通过命令行禁用/启用网络接口(以太网或 Wi-Fi)。无需管理员权限。如果您使用的是 Wi-Fi 适配器并已关闭“在范围内时自动连接”,如何重新建立互联网连接。进行更改,将其保存为 EnableDisableWireless.vbs,为其创建快捷方式(f:\myapps\windows\EnableDisableWireless.vbs),它将立即运行。
如何查找您的 NIC(网络接口卡/网络适配器/网络接口名称)名称:
netsh interface show interface
更改 NIC_Name:
str_NIC_Name = "Wi-Fi 2"
如果你正在使用以太网适配器,或者你有不是如果使用 wifi 注释掉“在范围内时自动连接”关闭:
'WScript.Sleep 1000
'Set objShell = WScript.CreateObject("WScript.Shell")
'objShell.Run "%windir%\System32\netsh.exe wlan connect name=COM_000352 ssid=COM_000352"
'Set objShell = Nothing
如果你正在使用 Wi-Fi 适配器,并且有关闭“在范围内时自动连接”:
如何查找您的 NIC 名称和 SSID:
netsh interface show interface
Netsh wlan show profiles
改变:
str_NIC_Name = "Wi-Fi 2"
objShell.Run "%windir%\System32\netsh.exe wlan connect name=COM_000352 ssid=COM_000352"
VBScript:
'~ Toggle a SPECIFIED NIC on or off. Re-establish internet connection if using wi-fi and you have turned off "Connect automatically when in range".
' https://www.wilderssecurity.com/threads/toggle-nic-on-off-with-vbs-xp-and-7.265836/
' Does not require admin privileges.
Option Explicit
Const NETWORK_CONNECTIONS = &H31&
Dim objShell, objFolder, objFolderItem, objEnable, objDisable
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 = "Wi-Fi 2"
' str_NIC_Name = "Ethernet"
' str_NIC_Name = "Local Area Connection 2"
' str_NIC_Name = "Local Area Connection"
' ========================================================
strEnable = "En&able"
strDisable = "Disa&ble"
' 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
End If
If clsVerb.Name = strDisable Then
Set objDisable = clsVerb
End If
Next
If bEnabled Then
objDisable.DoIt
WScript.Sleep 1000
' run ping to prove wireless adapter is disabled
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "%windir%\system32\ping.exe 8.8.8.8"
Set objShell = Nothing
Else
objEnable.DoIt
' ========================================================
' ===== Begin if you are working on an ethernet adapter or you have **not** turned off "Connect automatically when in range" if using wi-fi comment out the following four lines: ======
WScript.Sleep 1000
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "%windir%\System32\netsh.exe wlan connect name=COM_000352 ssid=COM_000352"
Set objShell = Nothing
' ===== End if you are working on an ethernet adapter or you have **not** turned off "Connect automatically when in range" if using wi-fi comment out the following four lines: ======
' ========================================================
End If
'~ Give the connection time to stop/start
WScript.Sleep 1000
WScript.Quit
如何使用 VBScript 通过命令行禁用/启用网络适配器。
如何通过命令行打开/关闭指定的网络适配器 NIC。
如何通过命令行打开/关闭网络适配器。
如何通过命令行打开/关闭指定的网络接口卡。