$unc =join(split($folder,":"),"$")

should be

$unc =join(split($sharepath,":"),"$")

Additionally, I'd just make an additional optional parameter for $Hidden and then do something like:
if $hidden $sharename = $sharename + '$' endif
$FileShare = $FService.Create ("FileShare", $ShareName)
_________________________
How to ask questions the smart way <-----------> Before you ask