Kent,

Ok - I have to admit it - this was painfull to code. It took me about a half day to do it but looking back - it's not so bad ... It's basically ripped from here and there on the web - but I mostly used the WMI SDK and MSDN ...

This script will automatically create an NTFS SHARE and permission it as EVERYONE:FULLCONTROL ... sorry for the lack of comments, etc ... I need a coffee REAL bad ...

It requires Windows 2000 or WindowsNT/9x with retro WMI installed.

Give it a shot ... now to study your script

code:

break on


; SET YOUR SPECIFICS ...


$servername = @wksta
$sharename = "TEMP"
$sharepath = "C:\TEMP"
$sharedescription = "My Temp Share"


dim $aces[1]


$wmi = getobject('winmgmts:{impersonationlevel=impersonate}!//$servername')


$secdesc = $wmi.get("win32_securitydescriptor")
$trustee = $wmi.get("win32_trustee")
$trustee.domain = ""
$trustee.name = "everyone"
$trustee.sid = 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0
$ace = $wmi.get("win32_ace")
$ace.accessmask = 2032127
$ace.aceflags = 3
$ace.acetype = 0
$ace.trustee = $trustee


$aces[0] = $ace
$secdesc.dacl = $aces


$share = $wmi.get("win32_share")
$create = $share.methods_("create")
$inparms = $create.inparameters
$inparms.access = $secdesc
$inparms.description = $sharedescription
$inparms.name = $sharename
$inparms.path = $sharepath
$inparms.type = 0
$share.execmethod_("create",$inparms)


exit


-Shawn

p.s. The new share doesn't auto-refresh in NT explorer. Close re-open explorer or use NET share to check-out !

[ 14 August 2001: Message edited by: Shawn ]