I have an Applescript that creates a user account on Mac OS X 10.7 but will not create the home folder. So when I login with the new user account, it yells at me that there is no home folder. I’ve tried other solutions I’ve seen on the interwebs, but with no luck. I’m still somewhat of a newb to Applescript and Macs, so I may be looking over something really simple. Here’s the script and what I’ve tried:
set shortUser to "testuser"
set longUser to "Testing User"
set userID to "1001"
set groupID to "staff"
set userPass to "test-123"
set theCommand to ""
set theCommand to theCommand & "/usr/bin/dscl . -create /Users/" & shortUser & ";"
set theCommand to theCommand & "/usr/bin/dscl . -create /Users/" & shortUser & " UserShell /bin/bash;"
set theCommand to theCommand & "/usr/bin/dscl . -create /Users/" & shortUser & " RealName " & quoted form of longUser & ";"
set theCommand to theCommand & "/usr/bin/dscl . -create /Users/" & shortUser & " UniqueID " & userID & ";"
set theCommand to theCommand & "/usr/bin/dscl . -create /Users/" & shortUser & " PrimaryGroup " & groupID & ";"
set theCommand to theCommand & "/usr/bin/dscl . -create /Users/" & shortUser & " NFSHomeDirectory /Users/" & shortUser & ";"
set theCommand to theCommand & "/usr/bin/dscl . -passwd /Users/" & shortUser & space & userPass & ";"
set theCommand to theCommand & "/usr/bin/dscl . -append /Groups/admin GroupMembership " & shortUser
do shell script theCommand with administrator privileges
I have tried changing:
set theCommand to theCommand & "/usr/bin/dscl . -create /Users/" & shortUser & " NFSHomeDirectory /Users/" & shortUser & ";"
to
set theCommand to theCommand & "/usr/bin/dscl . -create /Users/" & shortUser & " home /Users/" & shortUser & ";"
No success. I’ve also tried running each of the following commands with no success:
do shell script "sudo createhomedir -c -u testuser" with administrative privileges
do shell script "sudo createhomedir -l -u testuser" with administrative privileges
do shell script "sudo createhomedir -c" with administrative privileges
do shell script "sudo createhomedir -l" with administrative privileges
Whatever I do, I don’t see a folder “testuser” in the /Users/ directory, am I looking in the wrong place? All the other information seems to be working, I’m just having the home folder issue.
Thanks in advance.