*EDIT* Just noticed something. I've been testing on my local PC. When I ran a test on a remote PC I was able to create a "hidden" share by making the share name with a '$' symbol after it. No modifications to the UDF. (for what it's worth .... ?) So, perhaps It's not a big deal, unless you want to create a hidden share with this script on a local computer....???


I've tried all recommended alterations to the Function, but am still unable to create a hidden share. Any corrections/suggestions?

After adding the suggested DIMming I receive the following error: Code:

E:\kixtest>kix32.exe createlocalshare.kix

ERROR : undefined variable [unc]!
Script: E:\kixtest\UDF\CreateShare2.udf
Line : 21

E:\kixtest>



*New* CreateShare UDF:
Code:
 
;Example:
;
;$Server="server1"
;$SharePath="c:\test\share"
;$ShareName="Test Share"
;$Domain=
;$hidden=
;CreateShare($server,$shareName,$SharePath,$domain,$hidden)

Function CreateShare($Server, $ShareName, $SharePath, optional $Domain, optional $hidden)

Dim $iSO
$iSO=SetOption('Explicit','On')
$iSO=SetOption('NoVarsInStrings','On')
$iSO=SetOption('NoMacrosInStrings','On')


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


Initiating KiX Script:
Code:

call "@ScriptDir\UDF\MakePath.udf"
call "@ScriptDir\UDF\CreateShare2.udf"
$server="smith1"
$shareName="local"
$SharePath="c:\tempdrive"
;$Hidden =

CreateShare($Server, $ShareName, $SharePath,$domain,$hidden)



Edited by StarwarsKid (2005-10-03 07:20 PM)
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5