none
Enable/Disable of the network adapter through MSFT_NetAdapter

    Question

  • I'm trying disable/enable the network adapter through MSFT_NetAdapter in OS Windows 8.

    strComputer = "."
    
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=Delegate," _
            & "authenticationLevel=pktPrivacy}\root\standardcimv2")
    
    Set colSettings = objWMIService.ExecQuery("Select * from MSFT_NetAdapter")
    
    For Each objOperatingSystem in colSettings 
        Wscript.Echo _ 
        "DeviceID: " & objOperatingSystem.DeviceID & vbCrLf & _
        "Name: " & objOperatingSystem.Name
    objOperatingSystem.Disable
    
    Next

    For example use Disable only. MSFT_NetAdapter returns "DeviceID" or "Name", and when you call method objOperatingSystem.Disable get an error 0x80041003 "Current user does not have permission to perform the action". I try use this code:

    strComputer = "."
    
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=Delegate," _
            & "authenticationLevel=pktPrivacy}\root\cimv2")
    
    Set colSettings = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter where PhysicalAdapter = true")
    
    For Each objOperatingSystem in colSettings 
        Wscript.Echo _ 
        "DeviceID: " & objOperatingSystem.DeviceID & vbCrLf & _
        "DeviceID: " & objOperatingSystem.Name
        objOperatingSystem.Disable
    Next

    This code works fine on windows 7. The network adapter is switched immediately after the code. In OS windows 8 Disable/Enable requires a system reboot after the code.

    How to manage the network adapter in the OS windows 8?

    Monday, May 25, 2015 10:29 AM

Answers