Using those suggestions I have modified the UDF. Please check and verify if I made the changes correctly.
Code:
;Example:
;
;$Server ="server1"
;$SharePath ="c:\test\share"
;$ShareName ="Test Share"
;CreateShare($server,$shareName,$SharePath,,)
Function CreateShare($Server, $ShareName, $SharePath, optional $Domain, optional $hidden)
if not $domain $domain ="@domain" endif
if not $server $server ="@wksta" endif
if $hidden $sharename = $sharename + '$' endif
$unc =join(split($sharepath,":"),"$")
$uncpath="\\$server\$unc"
if not exist("$uncpath")
$path=makepath("$uncpath")
endif
$FService = GetObject ("WinNT://$Domain/$Server/LanmanServer,FileService")
$FileShare = $FService.Create ("FileShare", $ShareName)
$FileShare.Path = $SharePath
$FileShare.MaxUserCount = -1 ; -1 allows unlimited connections. Any other positive number
$FileShare.SetInfo
$FService = 0
$FileShare = 0
EndFunction
If I am understanding this correctly, would the syntax for using the modified UDF be as follows?
Code:
$Server ="server1"
$SharePath ="c:\test\share"
$ShareName ="Test Share"
CreateShare($server,$shareName,$SharePath,, 1 )