# Function Reference

# _Net_Share_ShareEnum

Retrieves information about each shared resource on a server

#include <NetShare.au3>
_Net_Share_ShareEnum ( [$sServer = ""] )

## Parameters

$sServer | [optional] String that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank the local computer is used.

## Return Value

Success: | an array with the following format: [0][0] - Number of entries in array [1][0] - Share name of a resource [1][1] - Type of the shared resource. Can be a combination of: $STYPE_DISKTREE - Disk drive $STYPE_PRINTQ - Print queue $STYPE_DEVICE - Communication device $STYPE_IPC - IPC $STYPE_SPECIAL - Special share reserved for IPC$ or remote administration of the server $STYPE_TEMPORARY - A temporary share [1][2] - Contains an optional comment about the shared resource [1][3] - Indicates the shared resource's permissions: 1 - Permission to read data from a resource and to execute 2 - Permission to write data to the resource 4 - Permission to create an instance of the resource 8 - Permission to execute the resource 16 - Permission to delete the resource 32 - Permission to modify the resource's attributes 64 - Permission to modify the permissions assigned to a resource [1][4] - Maximum number of concurrent connections for the resource [1][5] - Indicates the number of current connections to the resource [1][6] - Specifies the local path for the shared resource [1][7] - Specifies the share's password
Failure: | sets the @error flag to non-zero.

## Remarks

Administrator, Power User, Print Operator, or Server Operator group membership is required to execute this function.

## Related

_Net_Share_ConnectionEnum, _Net_Share_FileEnum, _Net_Share_SessionEnum

## See Also

Search NetShareEnum in MSDN Library.

## Example

    #include "Extras\HelpFileInternals.au3"

    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    #include <NetShare.au3>
    #include <WindowsStylesConstants.au3>

    #RequireAdmin ; needed for _Net_Share_ShareAdd() if needed

    Example()

    Func Example()
        Local $iI, $aInfo
        Local Const $sShareName = "AutoIt Share"
        Local Const $sResourcePath = "C:\"

        ; Create GUI
        GUICreate("NetShare", 400, 300)

        ; Create memo control
        _MemoCreate(2, 2, 396, 296, $WS_VSCROLL)
        GUISetState(@SW_SHOW)

        Local $bShareAdded = False
        ; See if the share exists
        If _Net_Share_ShareCheck(@ComputerName, $sResourcePath) = -1 Then
            ; Create a share on the local computer
            $bShareAdded = _Net_Share_ShareAdd(@ComputerName, $sShareName, 0, $sResourcePath, "AutoIt Share Comment")
            If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share add error : " & @error)
            _MemoWrite("Share added")
        Else
            _MemoWrite("Share exists")
        EndIf

        ; Show information about all local shares
        $aInfo = _Net_Share_ShareEnum(@ComputerName)
        _MemoWrite("Entries read ............: " & $aInfo[0][0])
        For $iI = 1 To $aInfo[0][0]
            _MemoWrite("Share name ..............: " & $aInfo[$iI][0])
            _MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
            _MemoWrite("Comment .................: " & $aInfo[$iI][2])
            _MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[$iI][3]))
            _MemoWrite("Maximum connections .....: " & $aInfo[$iI][4])
            _MemoWrite("Current connections .....: " & $aInfo[$iI][5])
            _MemoWrite("Local path ..............: " & $aInfo[$iI][6])
            _MemoWrite("Password ................: " & $aInfo[$iI][7])
            _MemoWrite()
        Next

        If $bShareAdded Then
            ; Delete the share
            _Net_Share_ShareDel(@ComputerName, $sShareName)
            If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share delete error : " & @error)
            _MemoWrite("Share deleted")
        EndIf
        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
    EndFunc   ;==>Example