Reputation: 1085
I am trying the below code to create a user and automatically create the home directory
user "username" do
supports :manage_home => true
comment "ChefUser"
home "C:\\Users\\username"
password "somepassword"
action :create
end
Below code also doesn't worked. It gave error "Error: NoMethodError: undefined method each_char for #array:0x4434
user "username" do
supports :manage_home => true
comment "ChefUser"
home "C:\\Users\\username"
password "somepassword"
action :create
provider Chef::Provider::User::Useradd
end
What I am doing wrong here.
Upvotes: 1
Views: 993
Reputation: 15784
Soundslike XY problem there.
I suspect you wish to create the use directory to set in some settings or documents for your users.
In windows the actual way to accomplish this is to work with default user
and all users
home dirs.
The content of All Users
will be merged with each users directory on the workstation (i.e: a shortcut placed in All Users\Desktop
will be on each user desktop and they can't delete it, usefull for support link or other parts shared by all users)
The content of Default User
is the User home Template, at the first connection of a user , this user home directory will be created by copying the content of what is in Default User
directory (including shortcuts on desktop, documents in the my document dir, etc.)
So the answer for your case is more to work on the Default User
or All Users
path than trying to create and work on each User Home dir. If there's scripts you wish to set there specific to each user, use %USERNAME%
and %USERPROFILE%
in thoose scripts to get the username and it's profiles diretory.
Upvotes: 3
Reputation: 54211
To quote to documentation:
When the Windows provider is used, Microsoft Windows does not create a home directory for a user until that user logs on for the first time; specifying the home directory does not have any effect as to where Microsoft Windows ultimately places the home directory.
Upvotes: 2