none
Permission Denied in Win32_NetworkAdapterConfiguration RRS feed

  • Question

  • Friend


       I tried to use the block code (a) below only that I'm having permission denied problem,
       Then I tried to use part of the block code (b), but it still did not work, and I'm working in a workgroup network.
       Would anyone have any idea how to resolve this permission denied problem?

    block code (a)
    ==============
    
    strMsg = ""
    strComputer = "."
    
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'")
    
    For Each IPConfig in IPConfigSet
     If Not IsNull(IPConfig.IPAddress) Then
     For i = LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
      If Not Instr(IPConfig.IPAddress(i), ":") > 0 Then
      strMsg = strMsg & IPConfig.IPAddress(i) & vbcrlf
      End If
     Next
     End If
    Next
    
    Echo strMsg
    
    
    
    block code (b)
    ==============
    
       Set objLocator = CreateObject("WbemScripting.SwbemLocator")
       'Set objSvc = objLocator.ConnectServer("note-server", "root\cimv2", ".\Administrator", "123a123")
       'Set objSvc = objLocator.ConnectServer("note-server", "root\cimv2", "WORKGROUP\administrator", "123a123")
       'Set objSvc = objLocator.ConnectServer("note-server", "root\cimv2", "/user:\domain\administrator", "123a123")
       'Set objSvc = objLocator.ConnectServer("note-server", "root\cimv2", "administrator", "123a123")
       'Set objSvc = objLocator.ConnectServer("note-server", "root\cimv2", ".\administrator", "123a123")
       Set objSvc = objLocator.ConnectServer("note-server", "root\cimv2", "Administrator", "123a123")
       
       Set objSet = objSvc.ExecQuery("select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled='true'")
    
    
    
    
    

    Sunday, March 26, 2017 12:35 PM