Search code examples
vbscriptwmiwindows-embedded-standard

Access is denied (80070005) when trying to retrieve WMI using SWbemLocator from remote machine


The remote machine I'm trying to connect to is as follows:

  • Windows Embedded standard 7 (SP1).
  • Configured in Workgroup.
  • The credentials I'm using are from an Admin account.
  • I have given all permissions to the group "Everyone" in the CIMV2 namespace, including all subfolders and entries (wmimgmt.msc).
  • I have given all permissions to the group "Everyone" for the 3 security options ("Launch and Activation Permissions", "Access Permissions" and "Configuration Permissions") for the WMI entry in the DCOM list from the Component Services (dcomcnfg.exe).
  • Windows firewall is disabled.

This is the code I'm using:

Dim remotets, objComputer, colComputereremote, strComputer
Dim objSWbemLocator, objWMIServiceremote

strComputer = "XTEMB4" 
WScript.Echo strComputer

'Get remote machine WMI service object  
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIServiceremote = objSWbemLocator.ConnectServer(strComputer, "root\CIMV2", "dts", _
"dts", "MS_409", "ntlmdomain:" & "")
Set colComputereremote = objWMIServiceremote.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objComputer in colComputereremote
    remotets = objComputer.LocalDateTime
    WScript.Echo remotets
Next

WScript.Quit

I have tried the same code with a Windows XP Embedded machine (same config as the Win7 machine) and it works fine.


Solution

  • After digging some related questions, I found a suggestion that worked for me: I had to add the user account whose credentials ("dts" and "dts" in my code) I was using to remotely access WMI to the groups "Distributed COM Users" and "Performance Monitor Users". This needs to be changed in the target remote Windows 7 machine.

    The information can be found in this link.

    Also, the information on how to add a user to specific groups in Windows 7 standard can be found here.