C# .NET - Remote WMI Connection issue

Asked By Sanjeev Sircar on 22-May-09 03:41 PM

i needed to get the free disk space on a shared remote drive.
my shared-name goes something like this -- \\RemoteServer\ADrive$

ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "xUser";
oConn.Password = "xxxx";
string sSrvName = @" \\RemoteServer\ADrive$";

ManagementScope oMS = new ManagementScope(sSrvName, oConn);

I get the error  - "Invalid Parameter".
If i remove the $ sign from the end of the server name and make it something like \\RemoteServer\ADrive
it goes past the above statement and fails  at
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMS, oQuery) ;
ManagementObjectCollection oReturnCollection = oSearcher.Get() ;

with the error -  "RPC server is unavailable"

but when trying to map the above mentioned share drive - \\RemoteServer\ADrive$, via Windows Explorer it works.
any kind of help is appreciated.

thanks to all

This should suffice

[)ia6l0 iii replied to Sanjeev Sircar on 23-May-09 12:53 PM
Both the cases "mapping a drive" and querying remote box with permissions using WMI is addressed at http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/51f3ad3f-cfc3-4793-b83a-cc7e852084c2