We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

VB script - create folder, map as specific drive letter.  Need to add user in Security tab

Ben Hart
Ben Hart asked
on
Medium Priority
602 Views
Last Modified: 2012-06-27
Here's the portion of our login script that creates, and maps a drive for a users folder.  I didn't realize it then, but this did not give the user modify rights.  Which is what I need help doing now.  I just want to add to the code I hve now, with what's needed to add the user to the security tab with modify rights.
''''''''''''''''''''''''''''''create user folder'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub CheckForUserFolder(UserName)
On Error Resume Next
Dim ObjFSO
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
	If Not(ObjFSO.FolderExists("\\jak-2k3-mss\users\" & UserName)) Then 
		Set newfolder = ObjFSO.CreateFolder("\\jak-2k3-mss\Users\" & UserName)
	End If
End Sub

Open in new window

Comment
Watch Question

greg wardSenior Systems Engineer
CERTIFIED EXPERT

Commented:
to change permissions you need the command cacls
cacls /? at the command prompt to see which switches you need.
The below link shows you how to use it with vb script.

http://www.appdeploy.com/messageboards/tm.asp?m=15015

Greg
IT Section Manager
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Is this for Active Directory users?  If so, you don't need to do this in a login script, you could just add a "Home Folder" to the user's "Profile" tab in AD Users and Computers.

If you have a large number of Users to add this do, in ADUC create a Query called "All Users" and Define the Query so that on the "Users" tab, "Name" "Has a Value" and run the query.  Select all the users in the result, right click and pick "Properties" and you'll be able to modify them all at once.

Go to the "Profile" tab, check the "Home Folder" box, select "Connect", choose a Drive Letter for the mapping and put in
\\jak-2k3-mss\users\%USERNAME%
for the value in the "To:" field.  

Once a user has a connected Home Folder value, the system should create the folder if it doesn't exist and automatically apply the rights needed for the user to use their home folder and also map the selected drive letter to the home folder each time they log in.

Author

Commented:
Thanks CitizenRon.. I recall we used to have a line similar to that in the Home Folder field however it never actually created the folder.  Last year when I had help creating this portion of the script I forgot totally about the Home Folder's use..  I will test it, as well as Jawa29's code..

Thanks both of you.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Ahh nice catch.  I'm fighting AV issues at the moment but glad you caught that.  Probably just a typo though.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.