Modify

Opened 8 years ago

Closed 8 years ago

#3632 closed Bug (Fixed)

The second parameter for _Net_Share_ShareCheck is incorrectly documented and inconsistent with related functions

Reported by: Bob Anthony Owned by: J-Paul Mesnage
Milestone: 3.3.15.1 Component: Standard UDFs
Version: 3.3.14.5 Severity: None
Keywords: NetShare.au3 Cc:

Description

Per the documentation, the second parameter for _Net_Share_ShareCheck is a share name. This would be consistent with the related functions; ShareAdd, ShareDel, ShareGetInfo. However, when given a share name the function returns -1 with extended 2311. The example script in the help file for this function fails when you comment the ShareDel line and run the script a second time.

I found that this function requires the share path to functions as expected. The code below shows that when given a share name the function returns -1. Swapping lines 6 and 7 shows that it functions as expected when passed the local path gathered from ShareGetInfo.

#include <NetShare.au3>

$sComputerName = @ComputerName
$aInfo = _Net_Share_ShareEnum($sComputerName)
For $iI = 1 To $aInfo[0][0]
	;If CheckShareByName($sComputerName, $aInfo[$iI][0]) = -1 Then
	If _Net_Share_ShareCheck ($sComputerName, $aInfo[$iI][0]) = -1 Then
		ConsoleWrite("Share " & $aInfo[$iI][0] & " does not exist" & @CRLF)
	Else
		ConsoleWrite("Share Name: " & $aInfo[$iI][0] & @CRLF)
		ConsoleWrite("Share Type: " & _Net_Share_ResourceStr($aInfo[$iI][1]) & @CRLF)
		ConsoleWrite("Share Path: " & $aInfo[$iI][6] & @CRLF & @CRLF)
	EndIf
Next

Func CheckShareByName($sServer, $sShareName)
	Local $aReturn = _Net_Share_ShareGetInfo($sServer, $sShareName)
	If @error Then Return SetError(@error, 0, -1)
	Return _Net_Share_ShareCheck($sServer, $aReturn[6])
EndFunc

Attachments (0)

Change History (1)

comment:1 by J-Paul Mesnage, 8 years ago

Milestone: 3.3.15.1
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [12152] in version: 3.3.15.1

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.