Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

server\share values -- Urgent


I have people that say that this can be done. have tried a number of things with no success.


the only thing that I know is that there is a folder named testfolder and a file named test.txt.

Is there anyway to get the two unknown values above?

  • 4
  • 3
1 Solution

If the folders are published in Active Directory, you can programitically use the code on this page to search for them

Or, (also if the folders are published in Active Directory), you can just search for them in AD Users and Computers by right clicking on domain, choose "find", then select "Shared Folders" in the Find drop down box.

IF they are NOT published, you may be stuck with, at a minimum, doing a 'for each' search on every server\share in the domain. This code can at least get you started by
'--Insert a For each loop here For every computer in domain
strComputer = ""
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")

StrConCat = "."

For each objShare in colShares
    'Instead of concatenating these to print them, you'd do a search here.
    StrConCat = StrConCat  &  "Name: " & objShare.Name     & VbTab & VbTab & VbTab
    StrConCat = StrConCat  &  "Path: " & objShare.Path     & VbCrLF
wscript.echo strConCat
earngreenAuthor Commented:
Sorry that will not work because then I will have to store VBS file with every app. I need something in pure VB.net.
Bob LearnedCommented:
Are you trying to find the server name and share name for a file path?

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

earngreenAuthor Commented:
Yes Bob

Really having a hard time with this one. I am currently working on a couple of things that i found out on the net but never attempted to do anything like this so am a little nervous about what I am going to do.

I found this which will return the network drives on the computer but I need to limit to one or two to search. having trouble with creating an array to store the drives. Then I could convert to a string and concatenate and filter as I would like.


I also found this


Don't know anything about VB6 trying to pass the filename as a parameter to the class and see what happens.

Any suggestions on how to find server name and share name and concatenate the file path?

Bob LearnedCommented:
I am still trying to figure out, though, if you have the full UNC name, or just a file name, without knowing the server name?  Or, do you want to search through mapped networks drives for that file path?

earngreenAuthor Commented:
I do not have the full UNC name. This is the problem.

For instance,

this part is known


and this part is unknown


Ideally I would like to get the server name and sharepath.
earngreenAuthor Commented:

I created this from the Code on this page using the fGetUNCPath function from http://www.mvps.org/access/api/api0003.htm  I am trying to store all the drives in array but having trouble with the array. I then will store the items in an array and concatenate the path. Then I want to check to see if the file exists, if so then complete the operation. If not return a message that says file not found.

The array below does not display properly. Not sure what the issue is. I also tried to
TotalUNCPath = ShowArray to return the array for display in a Sub but returned no values.

Any ideas?

Dim strAllDrives As String
        Dim strTmp As String
        Dim strTemp As String
        Dim StrReturnDrives As String
        Dim SfileName As String
        Dim UNCPath As String
        Dim i As Integer
        Dim UniversalPath As String

        strAllDrives = fGetDrives()
        If strAllDrives <> "" Then
                strTmp = Mid(strAllDrives, 1, InStr(strAllDrives, vbNullChar) - 1)
                'strTmp = Mid(strAllDrives, 1, InStr(strAllDrives, vbNullChar) + 1)
                strAllDrives = Mid(strAllDrives, InStr(strAllDrives, vbNullChar) + 1)

                Select Case fDriveType(strTmp)

                    Case "Network Drive"

                     UniversalPath = ((fGetUNCPath(Microsoft.VisualBasic.Left(strTmp, Len(strTmp) - 1).ToString)))

                        SfileName = UniversalPath
                        Dim ShowArray As String
                        Dim strArray(Len(SfileName)) As String
                        For i = 1 To Len(SfileName)
                            strArray(i) = strArray(i) & Mid(SfileName, i, 1)
                            ShowArray = strArray(i)
                End Select

         Loop While strAllDrives <> ""

        End If

    End Function
Bob LearnedCommented:
No ideas.


Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now