Function Reference


_Net_Share_ShareGetInfo

Retrieves information about a particular shared resource on a server

#include <NetShare.au3>
_Net_Share_ShareGetInfo ( $sServer, $sShare )

Parameters

$sServer 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.
$sShare Name of the share for which to return information

Return Value

Success: an array with the following format:
    [0] - Share name of a resource
    [1] - Type of the shared resource. Can be a combination of:
        $STYPE_DISKTREE - Print queue
        $STYPE_PRINTQ - Disk drive
        $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
    [2] - Contains an optional comment about the shared resource
    [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
    [4] - Indicates the maximum number of connections that the resource can have
    [5] - Indicates the number of current connections to the resource
    [6] - Specifies the local path for the shared resource
    [7] - Specifies the share's password
Failure: sets the @error flag to non-zero.

Remarks

Only members of the Administrators, Server Operators, or Power Users local group, or those with Print or
Server Operator group membership, can successfully execute this function.

Related

_Net_Share_FileGetInfo, _Net_Share_SessionGetInfo, _Net_Share_ShareSetInfo

See Also

Search NetShareGetInfo in MSDN Library.

Example

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

#RequireAdmin ; needed for _Net_Share_ShareAdd()

Global $g_idMemo

Example()

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

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

        ; Create memo control
        $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
        GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
        GUISetState(@SW_SHOW)

        Local $bShareAdded = False
        ; See if the share exists
        If _Net_Share_ShareCheck(@ComputerName, "") = -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)
                Else
                        MemoWrite("Share added" & @CRLF)
                EndIf
        Else
                MemoWrite("Share exists" & @CRLF)
        EndIf

        If $bShareAdded Then
                ; Show information about the share we added
                $aInfo = _Net_Share_ShareGetInfo(@ComputerName, $sShareName)
                MemoWrite("Share name ..............: " & $aInfo[0])
                MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[1]))
                MemoWrite("Comment .................: " & $aInfo[2])
                MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[3]))
                MemoWrite("Maximum connections .....: " & $aInfo[4])
                MemoWrite("Current connections .....: " & $aInfo[5])
                MemoWrite("Local path ..............: " & $aInfo[6])
                MemoWrite("Password ................: " & $aInfo[7])

                ; Delete the share
                _Net_Share_ShareDel(@ComputerName, $sShareName)
                If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share delete error : " & @error)
                MemoWrite(@CRLF & "Share deleted")

                ; Loop until the user exits.
                Do
                Until GUIGetMsg() = $GUI_EVENT_CLOSE
        EndIf

EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
        GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite