473,395 Members | 1,527 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,395 software developers and data experts.

How to get the path of share folder "ADMIN$" on a remote machine?

hi,

i'm writing a application that need to get the path of share folder "ADMIN$"
on a remote machine. for instance, if "ADMIN$" is maped to "C:\Windows", i
want to get the string "C:\Windows".

Thanks in advance.
-Zhilin
Oct 26 '06 #1
4 5181
Hi,

I think the "\\MachineName\ADMIN$" should work.

string folderName = @"\\MachineName\ADMIN$";
string[] subFolderNames = Directory.GetDirectories(folderName);

Make sure the running user account has sufficient rights to access that
folder.

Hope it helps,
Thi
http://thith.blogspot.com

Oct 26 '06 #2

Opps, mistaken. You want to get the actual path, like "C:\Windows".
Discard it.

Truong Hong Thi wrote:
Hi,

I think the "\\MachineName\ADMIN$" should work.

string folderName = @"\\MachineName\ADMIN$";
string[] subFolderNames = Directory.GetDirectories(folderName);

Make sure the running user account has sufficient rights to access that
folder.

Hope it helps,
Thi
http://thith.blogspot.com
Oct 26 '06 #3
Because I already tried to answer, I will try again.
I tested and the following code should work:

using System.Management;

private static string GetAdminPath(string computerName)
{
if (computerName == null || computerName.Length == 0) computerName =
Environment.MachineName;
ManagementClass c = new
ManagementClass(String.Format(@"\\{0}\root\cimv2:W in32_Share",
computerName));

foreach (ManagementObject o in c.GetInstances())
{
if ((string) o["Name"] == "ADMIN$") return (string) o["Path"];
}

return null;
}

Note that it is likely that the running user must have admin right on
that machine, just as when you check this with Control Panel's Computer
Management.

Thi
http://thith.blogspot.com

Oct 26 '06 #4
You will need to PInvoke NetShareGetInfo() in NetApi32.dll (I don't think
there is a equivalent .net framework class).
..
"CAIBird" <CA*****@discussions.microsoft.comwrote in message
news:D3**********************************@microsof t.com...
hi,

i'm writing a application that need to get the path of share folder
"ADMIN$"
on a remote machine. for instance, if "ADMIN$" is maped to "C:\Windows", i
want to get the string "C:\Windows".

Thanks in advance.
-Zhilin

Oct 26 '06 #5

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

Similar topics

4
by: Daniel P. | last post by:
I'm using C#: Stream s = File.Open( @"\remotemachine\share\MyFile.txt" , FileMode.Open , FileAccess.Read , FileShare.Read ); I'm getting the following exception: "The referenced account...
0
by: Learner | last post by:
Hello, we are using Master Pages in asp.net 2.0. Our Master page has three contentplaceholders. On the left most ContentPlaceHolder we have all the links for the navigation of the site. One of the...
2
by: schaf | last post by:
Hi Ng ! I'm a little confused because of my application. I need to access a file in the path C:\Temp\test.txt on a computer in the same network. Now I just know the IP address of this PC. Is it...
2
by: Tor Inge Rislaa | last post by:
I am prompted to implement the syntax below to be able to monitor the error on the remote server trough my browser (client). I can't seem to find where to place the code in my web.config file to...
7
by: =?Utf-8?B?YXVsZGg=?= | last post by:
hello, i'm try to research the way to open a remote machine's to collect the services and processes. i have the local data collection running but i can not figure out what MSDN or the C# help file...
3
by: dianedebuda | last post by:
Using only Access 97. Need to run as admin in order to use Tool /Compact, etc. Tried Allen Browne's suggestion about registry hack meant for multiple versions of Access, but doesn't seem to work...
0
by: =?Utf-8?B?U2FsaW0=?= | last post by:
Hi .Net gurus, I have a .Net C# application. I need to set permission for a domain user on given file share. Admin specifies the file share name as \\machine-name\shared Folder and user name...
2
by: gihope | last post by:
I have searched everywhere for answers to this but none of the posts I have read have helped yet. My website works perfectly until I upload it onto a remote web host. When this happens the logisn...
0
by: amitcool1982 | last post by:
I am getting the path of share folder "ADMIN$" on a remote machine but this command have any user account issue. if it have any issues then what is the issue. If any developer have any clue then...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.