Re: select directory on remote machine using WMI
- From: "CosminB [BRT]" <cosminb@xxxxxxxxx>
- Date: 18 Sep 2006 04:41:14 -0700
Willy Denoyette [MVP] wrote:
"CosminB [BRT]" <cosminb@xxxxxxxxx> wrote in message
news:1158577832.412730.81360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|I thought this is the way to go... any other ideas?
No, this is one way to go but maybe not the best.
The DirectoryInfo class accepts a UNC path like \\\\MyServer\\MyShare, so
you may use this one to connect/access a remote share or drive. Sure you
need access privileges to the remote resource, but this can be achieved by
1) impersonation or 2) by establishing a network session with the resource.
Option 2 is simple, just issue a 'net use ...' command (from the commandline
or using Process.Start), specifying the network path and the credentials
needed. Option 1 is more involving and wight not work if the client is
running W2K, basically you have to retrieve an access token by calling
LogonUser through PInvoke specifying the credentials for which you want to
obtain a token, use this token to Impersonate. Search MSDN for a sample
(look for LogonUser).
Willy.
I need to be sure it works on W2K also. As for option 2, I need to be
able to select any drive the remote host has... anyway, I've found a
way, with WMI, like this:
SELECT * FROM CMI_LogicalFile WHERE Path="\\somepath\\" AND Drive="X:"
and the drives, I get them with:
SELECT * FROM CMI_LogicalDisk
I don't mind doing a little extra work, but this seems fine, I hope it
will work well.
Thanks for the quick replies,
Cosmin.
.
- References:
- select directory on remote machine using WMI
- From: CosminB [BRT]
- Re: select directory on remote machine using WMI
- From: Willy Denoyette [MVP]
- Re: select directory on remote machine using WMI
- From: CosminB [BRT]
- Re: select directory on remote machine using WMI
- From: Willy Denoyette [MVP]
- select directory on remote machine using WMI
- Prev by Date: Re: converting string to byte array
- Next by Date: Re: Strong Name Verification Failed
- Previous by thread: Re: select directory on remote machine using WMI
- Next by thread: Rearrange definitions to top of class?
- Index(es):
Relevant Pages
|