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!
  • Students Click Here

*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.

Students Click Here

Microsoft: FoxPro FAQ


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
    wait window "No Computers Available" nowait
    wait window "Gathering Available Shares for Each Computer in Domain" nowait
        IF Anetresources(ShareNames,Alltr(computer_name),1)=0
            Select CAvailable_Shares
            Append Blank
            Replace share_name With "No Shares Present on "+Alltr(lcThisComputer)
            Replace shareltr With "XXX"
        FOR ShareCount = 1 To Anetresources(ShareNames,Alltr(computer_name),1)
            Select CAvailable_Shares
            Append Blank
            Replace share_name With ShareNames(ShareCount)

*- Read through List of Available Shares and enumerate Local Drive Mapping
Select CAvailable_Shares
    wait window "No Shares Available" nowait
    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))+"\"

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
        REPLACE share_name WITH (cDesktopPath)+"\"+NetworkArray(x,1)
        REPL shareltr WITH "ftp"
&&end snippet from FAQ184-4264
*- View Results
Go Top
Brow Nowait

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

My Archive

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