2

I want to be able to get the physical path (C:\somepath...) corresponding to an UNC path to a network share on the local computer (\\mycomputer\somepath...).

I've tried doing this using ManagementObjectSearcher as described here. This works fine when running as an Adminstrator, but fails when running from a non-privileged account.

No exception is thrown, the SelectQuery simply returns a ManagementObject whose path property is null.

I would like to be able to get this information from a non-privileged account, without adding the account to privileged groups such as Administrators or Power Users.

Can anyone indicate how to do this - what are the minimum privileges needed to execute this query successfully?

I've tried giving permission to the account as described here using Computer Management / WMI Control / Security but this makes no difference - even if I give all permissions to the Root node with Apply onto "this namespace and subnamespaces".

Joe
  • 122,218
  • 32
  • 205
  • 338

1 Answers1

1

You would need to give users the ability to execute remote WMI queries, there's an overview at http://msdn.microsoft.com/en-us/library/aa393266.aspx of the DCOM configuration needed.

In order to change WMI security from the Windows GUI:

  • Open a 'Manage Computer' for the target computer
  • Open the 'Services and Applications' section
  • Right-click on 'WMI Control' and choose 'Properties'
  • Select the security tab, click the Security button, and make the changes - add the 'Remote Enable' privilege to your target group or user.
stuartd
  • 70,509
  • 14
  • 132
  • 163
  • Stuart, I want to do this on the local machine only - so no need for remote permissions. I've tried giving permission via WMI Control / Properties to the account, but this has no effect - even if I give all permissions to the root node with Apply onto This namespace and subnamespaces. – Joe Sep 28 '11 at 11:43
  • Sorry. You could parse the output of the net share command, that might be easier! – stuartd Sep 28 '11 at 11:50
  • "parse the output of the net share command" - but presumably that also would require the account to have permission to enumerate shares. – Joe Sep 28 '11 at 13:47
  • Regular users have read access to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Shares – stuartd Sep 28 '11 at 16:15
  • +1 for the registry suggestion, which works. Seems strange that this registry entry is readable for normal users, but enumerating shares is not allowed. Nevertheless, I'm reluctant to use an undocumented technique that may change in future versions of Windows. – Joe Sep 29 '11 at 06:00