Announcement

Collapse
No announcement yet.

Enum Network Shares

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Enum Network Shares

    How do I programically display all network shares?

    eg, typing NET USE > G.TXT

    contents of g.txt
    -------

    Status Local name Remote name
    ------------------------------------------------------
    OK I: \\SERVER1\INTRANET
    OK J: \\SERVER1\USERS
    OK K: \\SERVER2\GENGLE
    OK M: \\4TH_SHIFT\FSHIFT
    Disconnected S: \\SANDBOX\FSHIFT
    OK U: \\SERVER3\GENGLE
    OK Y: \\SERVER1\SQLLABOR
    OK Z: \\SERVER1\LABOR
    OK LPT1 \\4TH_SHIFT\NEWOPTRAS
    Disconnected LPT3 \\SERVER1\LEXMARK_LSR
    OK \\SERVER1\INTRANET
    OK \\EXCHANGE1\IPC$
    The command was completed successfully.


    ------------------
    -Greg
    -Greg
    [email protected]
    MCP,MCSA,MCSE,MCSD

  • #2
    Gregery,

    I use this routine to disconnect all my network shares.
    If you leave "WNetCancelConnection2" out, a message box displays all the shares found.
    The message is in Dutch. To help you ASAP I did'nt change that.
    Code:
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    #RESOURCE "NETQUIT.PBR"          ' to include an appropriate icon for a desktop shortcut
    
    FUNCTION PBMAIN() AS LONG
      LOCAL szDrivLettr AS ASCIIZ * 3, szShare AS ASCIIZ * 64
      LOCAL count AS LONG, DriveType AS LONG, result AS STRING
    
      FOR count = 4 TO 26
        szDrivLettr = CHR$(count + 64) + ":"
        DriveType = GetDriveType(szDrivLettr)
        IF DriveType = %DRIVE_REMOTE THEN
          WNetGetConnection szDrivLettr, szShare, 64
          result = result + szDrivLettr + szShare + CHR$(13, 10)
          ' WNetCancelConnection2 szDrivLettr, %CONNECT_UPDATE_PROFILE, 0
        END IF
      NEXT
      caption$ = "Netwerk ontkoppelen"
      IF LEN(result) THEN
        MSGBOX "De volgende netwerkschijven" + CHR$(13, 10) + _
               "zijn ontkoppeld:" + CHR$(13, 10, 13, 10) + _
               result, 64, caption$
      ELSE
        MSGBOX "Geen netwerkschijven !", 16, caption$
      END IF
    END FUNCTION


    ------------------
    mailto:[email protected][email protected]</A>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

    Comment


    • #3
      gregery, also see here for simple pb/cc source: http://www.powerbasic.com/support/pb...ad.php?t=18043

      best regards,
      wayne


      ------------------
      -

      Comment

      Working...
      X