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

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

server\share values -- Urgent

Hi,

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

\\unknown\unknown\testfolder\test.txt

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?


0
earngreen
Asked:
earngreen
  • 4
  • 3
1 Solution
 
goober7Commented:

If the folders are published in Active Directory, you can programitically use the code on this page to search for them
http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_wkqv.mspx?mfr=true

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
Next
      
wscript.echo strConCat
0
 
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.
0
 
Bob LearnedCommented:
Are you trying to find the server name and share name for a file path?

Bob
0
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.

http://www.mvps.org/access/api/api0003.htm

I also found this

http://www.freevbcode.com/ShowCode.asp?ID=446

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?


0
 
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?

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

For instance,

this part is known

\testfolder\test.txt

and this part is unknown

\\servername\share

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

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
           
            Do
                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)
                            Debug.WriteLine(ShowArray)
                        Next
                       
                End Select


         Loop While strAllDrives <> ""
     


        End If
       

    End Function
0
 
Bob LearnedCommented:
No ideas.

Bob
0

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