473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

select directory on remote machine using WMI

Hi,

How can this be done? I've searched the internet for a solution to this
problem, and can't find a clear answer. I need to be able to browse a
remote computer's filesystem, using a certain user and password, and
select a storage location (for some files to be created later). I've
seen that WMI has Win32_Directory, but I don't know how find which
files are contained in a specific directory. I was thinking of using a
query select which would filter from all entries, only the ones that
are in a specific directory, but I don't know how. Is there
documentation for the WMI Query Language?

Hope someone can help...

Thanks in advance,
Cosmin.

Sep 18 '06 #1
4 7404

"CosminB [BRT]" <co*****@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
| Hi,
|
| How can this be done? I've searched the internet for a solution to this
| problem, and can't find a clear answer. I need to be able to browse a
| remote computer's filesystem, using a certain user and password, and
| select a storage location (for some files to be created later). I've
| seen that WMI has Win32_Directory, but I don't know how find which
| files are contained in a specific directory. I was thinking of using a
| query select which would filter from all entries, only the ones that
| are in a specific directory, but I don't know how. Is there
| documentation for the WMI Query Language?
|
| Hope someone can help...
|
| Thanks in advance,
| Cosmin.
|

The docs for WMI are in the Platform SDK documnetation and in the MSDN
library.
Question is why you want to use WMI for this?

Willy.
Sep 18 '06 #2
I thought this is the way to go... any other ideas?

Willy Denoyette [MVP] wrote:
"CosminB [BRT]" <co*****@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
| Hi,
|
| How can this be done? I've searched the internet for a solution to this
| problem, and can't find a clear answer. I need to be able to browse a
| remote computer's filesystem, using a certain user and password, and
| select a storage location (for some files to be created later). I've
| seen that WMI has Win32_Directory, but I don't know how find which
| files are contained in a specific directory. I was thinking of using a
| query select which would filter from all entries, only the ones that
| are in a specific directory, but I don't know how. Is there
| documentation for the WMI Query Language?
|
| Hope someone can help...
|
| Thanks in advance,
| Cosmin.
|

The docs for WMI are in the Platform SDK documnetation and in the MSDN
library.
Question is why you want to use WMI for this?

Willy.
Sep 18 '06 #3

"CosminB [BRT]" <co*****@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
|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.


Sep 18 '06 #4
Willy Denoyette [MVP] wrote:
"CosminB [BRT]" <co*****@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
|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.

Sep 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: iqbal | last post by:
Hi all, We have an application through which we are bulk inserting rows into a view. The definition of the view is such that it selects columns from a table on a remote server. I have added the...
1
by: Swarna | last post by:
Hi all, I am trying to find out whether a particular directory is present on a remote machine or not from my local Python script in Linux . Can anyone help me with the command that i need to...
5
by: Michael C | last post by:
....on a remote machine? Thanks, Michael C.
1
by: Ollie | last post by:
I know this has been asked before, I have read the answers given and I am unable to get this work ( I don't know that much about AD configuration) I have an asp.net web service that is designed...
9
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated...
11
by: Steve Franks | last post by:
I'm using VS.NET 2005 Beta 2. I have a helper C# class I wrote that I placed in my /App_Code directory. Everything runs fine locally. However when I use the "Copy Web" function to upload the site...
2
by: enrique | last post by:
Hello everyone, I'm looking for a "directory path" solution that will allows me to test my app locally and then test on remote web server without having to update my web.config file each time I...
1
by: jyohere | last post by:
How to access a remote machine directory from a local machine....I tried something like this: opendir(DIR,"192.168.9.62:/home/cygnet/Marconi_PM_Simulator/conf/"); @files = readdir(DIR); ...
2
by: sbettadpur | last post by:
hello everybody, i need a small script that should read the directories of remote machine which is in LAN. i tried with function called "opendir". but this fill read only local machine...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.