Computing.Net > Forums > Programming > VBscripting to create folders

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VBscripting to create folders

Reply to Message Icon

Name: kiwi_hk
Date: September 26, 2005 at 08:54:36 Pacific
OS: WIndows 2003
CPU/Ram: 2G
Comment:

Hi
I downloaded the VBscript file to create folders for my users in AD, but I am not a VBS programmer, can anybody help me in changing it so I can use a specific OU to create the folders. At the moment it creates the whole domain. Here is the script from Microsoft Q234746

Sub GetParentDir
ParentDir = InputBox("Type the path of the parent folder for the user folders:", "Parent Directory Input Prompt", ParentDir)
If Not FS.FolderExists(ParentDir) Then
GetParentDir
End If
End Sub

Dim WSHNetwork, WSHShell, FS, Domain, DomainObj, Computer, ShareServiceObj, ParentDir, Hidden, Drive
Set FS = CreateObject("Scripting.FileSystemObject")
Set WSHNetwork = CreateObject("WScript.Network")
Set ShareServiceObj = GetObject("WinNT://" & WSHNetwork.ComputerName & "/LanManServer")

Domain = InputBox("Type the name of your domain:","Enumeration and Creation of User Shares","DomainName")
ParentDir = "C:\Users"
GetParentDir
Hidden = MsgBox("Do you want the user shares to be hidden? If yes, the share will be username$; If no, the share will be username", 4, "Hidden Shares?")
Hidden = Hidden - 7
Drive = InputBox("What drive letter do you want to map the home folder to?", "Drive Letter?", "X:")
Set DomainObj = GetObject("WinNT://" & Domain)
DomainObj.Filter = Array("User")

For Each UserObj in DomainObj
Dim ShareName
If Not FS.FolderExists(ParentDir & "\" & UserObj.Name) Then
FS.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 = "\\" & WSHNetwork.ComputerName & "\" & ShareName
UserObj.HomeDirDrive = Drive 'Requires ADSI 2.5
UserObj.SetInfo
End If
Next

MsgBox "Script Complete",, "Finished"

By the way the script doesn't actually share the folders out in Windows 2003, it just create them, even though it ask me to shared them with a hidden $.

Thanks

Ken



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: September 26, 2005 at 13:46:27 Pacific
Reply:

OU?

Michael J


0

Response Number 2
Name: kiwi_hk
Date: September 26, 2005 at 19:41:15 Pacific
Reply:

Hi

It's for a server. eg. Windows 2003 server.

OU is Organization unit.

I have created one for my users,

Ken


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VBscripting to create folders

Using VBScript to create an account www.computing.net/answers/programming/using-vbscript-to-create-an-account/15416.html

batchfile to create folders from fi www.computing.net/answers/programming/batchfile-to-create-folders-from-fi/17066.html

Creating folders automatically! www.computing.net/answers/programming/creating-folders-automatically/17214.html