So I need to make a folder on every users homefolder. Lets call the folder "test". So then we would have \\server\users\username\test folder.

And then I need the folder to be shared with "test_username".

We have a system that checks for a folder and then it dumps automatically files there. It can be any script that I can run from command line. It only need to be run once. When I have the folders there and shared I'm happy. But it would be nice to have it on the login script because when new users come in, then it would be created when she or he logs in.

Here is what I have so far...

$Directory="\\server\users\"+@USERID
$DirectoryTemp="\\server\users\"+@USERID+"\testfolder"
If Not Exist ($Directory)
MD $Directory
Shell "%COMSPEC% /c Echo Y| Cacls \\server\users\"+@USERID+" /e /c /g "+@DOMAIN+\+@USERID+":F"
EndIf

If Not Exist ($DirectoryTemp)
MD $DirectoryTemp

Shell "%COMSPEC% /c Echo Y| Cacls \\server\users\"+@USERID+"\testfolder /e /c /g "+@DOMAIN+\+@USERID+":F"
EndIf

$ShareName = "test"
$ServerName = "server"
$SharePath = "\\" + $ServerName + "\Users\" + "\%username%\" + $ShareName
$Discription = "test folder share."

CreateShareFolder($ServerName,$ShareName,$SharePath,$Discription)

Function CreateShareFolder($ServerName,$ShareName,$SharePath,$Discription)

$FILE_SHARE = 0
$MAXIMUM_CONNECTIONS = -1 ; -1 allows unlimited connections.
$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $ServerName + "\root\cimv2")
$objNewShare = $objWMIService.Get("Win32_Share")
$FileShare = $objNewShare.Create($SharePath,$ShareName,$FILE_SHARE,$MAXIMUM_CONNECTIONS,$Discription)

EndFunction

-Fredu


Edited by Fredu (2006-10-02 05:33 PM)