Hi I was working on a similar script. However, mine uses the resource kit command line tools subinacl and rmtshare since they do exactly what I want them to do (lazy me).
However, net user does not do exactly what I want--I can't point it at a specific domain or NT box. So I am asking for help with using ADSI instead.
I have the VB code in there, but I can't figure out the syntax to make kix run it.
I have the two lines that do not work commented out.
code:
break on
cls$HomeDrive="H:"
$Computer="DCI41889"
$Drive="D"
$Path="\homes\"
$Domain="DCI41889"
WHILE 1
$UserID=Input("User ID")
If LEN($UserID)<2
QUIT
Endif
$UserObj=getobject("WinNT://"+$Domain+"/"+$Userid+",user")
If @ERROR=0
$UNC="\\"+$Computer+"\"+$Drive+"$"+$Path+$UserID
If not EXIST($UNC)
md $UNC ? "Made directory"
Else
? $UNC+" directory already exists"
EndIf
$Share="\\"+$Computer+"\"+$UserID+"$"
If not EXIST($Share)
SHELL "rmtshare.exe "+$Share+"="+$Drive+":"+$Path+$UserID+" /grant everyone:c"
? $Share+" Has been shared"
Else
? $Share+" Share already exists"
EndIf
SHELL "subinacl.exe /noverbose /subdir "+$UNC+" /grant="+$Domain+"\"+$Userid+"=C"
SHELL "net user "+$UserID+" /homedir:"+$Share+" /domain"
; UserObj.put "HomeDirectory", $Share
; UserObj.put "HomeDirDrive", $HomeDrive
; UserObj.SetInfo
UserObj=""
Else
? "User ID not found in "+$Domain
EndIf
LOOP
Function Input($Prompt)
DO
? $Prompt+":"
GETS $Input
UNTIL $Input
EndFunction