HI
I am working on a script to create shared folders for all users in a domain, here is the script
'script to create users shares for all users in a domain
Sub GetParentDir
ParentDir = "\\modrl\drives\home\"
If Not objFSO.FolderExists(ParentDir) Then
GetParentDir
End If
End Sub
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
Set ShareServiceObj = GetObject("WinNT://" & objNetwork.ComputerName & "/LanManServer")
Domain = "rldom"
ParentDir = "C:\drives\home\"
GetParentDir
Drive = "L:"
Set DomainObj = GetObject("WinNT://" & Domain)
DomainObj.Filter = Array("User")
For Each UserObj in DomainObj
If Not objFSO.FolderExists(ParentDir & "\" & UserObj.Name) Then
objFSO.CreateFolder(ParentDir & "\" & UserObj.Name)
End If
ShareName = UserObj.Name
If Hidden Then
ShareName = ShareName & "$"
End If
On Error Resume Next
Set NewShare = ShareServiceObj.Create("fileshare", ShareName)
If Not Err Then
NewShare.Path = ParentDir & "\" & UserObj.Name
NewShare.MaxUserCount = 1 'Sets the limit for the number of user connections
NewShare.SetInfo
UserObj.HomeDirectory = "\\" & objNetwork.ComputerName & "\" & ShareName
UserObj.HomeDirDrive = Drive
UserObj.SetInfo
End If
Next
The script creates all the folders for all the users in my domain but doesnt share the folders.
Can someone point out where I am going wrong
Thanks
I am working on a script to create shared folders for all users in a domain, here is the script
'script to create users shares for all users in a domain
Sub GetParentDir
ParentDir = "\\modrl\drives\home\"
If Not objFSO.FolderExists(ParentDir) Then
GetParentDir
End If
End Sub
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
Set ShareServiceObj = GetObject("WinNT://" & objNetwork.ComputerName & "/LanManServer")
Domain = "rldom"
ParentDir = "C:\drives\home\"
GetParentDir
Drive = "L:"
Set DomainObj = GetObject("WinNT://" & Domain)
DomainObj.Filter = Array("User")
For Each UserObj in DomainObj
If Not objFSO.FolderExists(ParentDir & "\" & UserObj.Name) Then
objFSO.CreateFolder(ParentDir & "\" & UserObj.Name)
End If
ShareName = UserObj.Name
If Hidden Then
ShareName = ShareName & "$"
End If
On Error Resume Next
Set NewShare = ShareServiceObj.Create("fileshare", ShareName)
If Not Err Then
NewShare.Path = ParentDir & "\" & UserObj.Name
NewShare.MaxUserCount = 1 'Sets the limit for the number of user connections
NewShare.SetInfo
UserObj.HomeDirectory = "\\" & objNetwork.ComputerName & "\" & ShareName
UserObj.HomeDirDrive = Drive
UserObj.SetInfo
End If
Next
The script creates all the folders for all the users in my domain but doesnt share the folders.
Can someone point out where I am going wrong
Thanks