INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Networking

Enumerate Available Shares and Current Mapping by baltman
Posted: 17 Nov 03 (Edited 22 Nov 03)


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&
&&&&& Enumerate Available Shares and Current Mapping
&&&&&
&&&&& This program was born in Thread184-707428. The
&&&&& code below was heavily contributed to by
&&&&& ChrisRChamberlain and ramani.
&&&&&
&&&&& As robsuttonjr suggested, it is possible to search
&&&&& all domains, but this is not always a good idea.
&&&&& Depending on network size, this could take a _very_
&&&&& long time to implement.
&&&&&
&&&&& I may add support for domains that are already mapped
&&&&& to a drive letter in the future.
&&&&&
&&&&& Code creates a mapping of all currently available
&&&&& computers, shared drives in the same Domain, and
&&&&& ftp sites mapped in the NetHood.
&&&&&
&&&&& Brian Altman
&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

*- Create a List of Computers in the Domain using NET VIEW
wait window "Creating List of Computers in the Domain" nowait
lcCmd = Getenv("ComSpec") + " /C NET VIEW > c:\temp\myNet.txt"
loWs  = Createobject("wscript.shell")
= loWs.Run(lcCmd,0,.T.)

*- Create a cursor to store all available shares and Local Drive Mapping (if any)
Create Cursor CAvailable_Shares (shareltr c(3), share_name c(150))

*- Create a cursor and store List of Computers in the Domain from NET VIEW
Create Cursor CComputer_names (computer_name c(23))
Append From c:\temp\myNet.txt Type Sdf For Left(computer_name,2) == "\\"
Erase c:\temp\myNet.txt

*- Read through List of Computers and gather available shares
IF RECCOUNT()=0
    wait window "No Computers Available" nowait
    RETURN
ELSE
?TIME()
    wait window "Gathering Available Shares for Each Computer in Domain" nowait
    SCAN
        IF Anetresources(ShareNames,Alltr(computer_name),1)=0
            lcThisComputer=computer_name
            Select CAvailable_Shares
            Append Blank
            Replace share_name With "No Shares Present on "+Alltr(lcThisComputer)
            Replace shareltr With "XXX"
        ELSE
        FOR ShareCount = 1 To Anetresources(ShareNames,Alltr(computer_name),1)
            Select CAvailable_Shares
            Append Blank
            Replace share_name With ShareNames(ShareCount)
        ENDFOR
        ENDIF
    ENDSCAN
ENDIF

*- Read through List of Available Shares and enumerate Local Drive Mapping
Select CAvailable_Shares
IF RECCOUNT()=0
    wait window "No Shares Available" nowait
    RETURN
ELSE
    wait window "Gathering Current Mapping Information" nowait
    WshNetwork = Createobject("WScript.Network")
    oDrives = WshNetwork.EnumNetworkDrives
   BROWSE nowait
    For i = 0 To oDrives.Count - 1 Step 2
        Locate For Alltr(Lower(oDrives.Item(i+1)))==Alltr(Lower(share_name))
        If found() AND LEN((oDrives.Item(i)))>0
            Repl shareltr With (oDrives.Item(i))+"\"
        Endif
    Next
ENDIF

wait window "Searching for NetHood ftp Mappings" nowait
*- Find NetHood folder and enumerate folders not belonging to LAN computers (ftp maps)
&&Adapted from FAQ184-4264 by slighthaze
LOCAL cSpecialFolderPath, cDesktopPath
cSpecialFolderPath = space(255)

DECLARE SHGetSpecialFolderPath IN SHELL32.DLL ;
LONG hwndOwner, ;
STRING @cSpecialFolderPath, ;
LONG nWhichFolder

SHGetSpecialFolderPath(0, @cSpecialFolderPath, 0x0013)
cDesktopPath = Alltrim(cSpecialFolderPath)
cDesktopPath = SubStr(cDesktopPath,1, Len(cDesktopPath)-1)

lcftpFolders = cDesktopPath + [\*.*]

FOR x= 1 TO ADIR(NetworkArray,lcftpFolders,'hd')
    IF "(" $ NetworkArray(x,1)=.F. AND ")" $ NetworkArray(x,1)=.F. AND LEFT(NetworkArray(x,1),1)#"."    ;
        AND NetworkArray(x,1) # [COMPUTERS NEAR ME]
        SELECT CAvailable_Shares
        APPEND BLANK
        REPLACE share_name WITH (cDesktopPath)+"\"+NetworkArray(x,1)
        REPL shareltr WITH "ftp"
    ENDIF
ENDFOR
&&end snippet from FAQ184-4264
*- View Results
Go Top
Brow Nowait

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close