[英]How can I create users and assign group from a text file with a batch script?
First, here's an example of what the text file contains. 首先,这是文本文件包含的示例。
bob,supervisor 鲍勃,监事
mary,technician 玛丽,技师
shane,user 巴蒂尔,用户
As you may see, on the left is how the user account name would be and on the right is the name of their group they have to be assigned to. 您可能会看到,左边是用户帐户名的样子,右边是必须分配给他们的组名。 These groups are already created.
这些组已创建。 Also, the password isn't written in the text file, but it would be the same for everyone (example: 123).
同样,密码没有写在文本文件中,但是每个人的密码都是相同的(例如:123)。 In this example, I only gave an example with 3 users in the file, but the file could also have 100 users to create and assign in it.
在此示例中,我仅给出了一个示例,该文件中有3个用户,但是该文件中也可以有100个用户来创建和分配。
I have tried a lot of different ways to make this work, but I just can't figure it out, so if someone could help me, that would be insanely useful. 我尝试了许多不同的方法来完成这项工作,但我只是想不通,所以如果有人可以帮助我,那将非常有用。
如果您需要这些用户成为本地用户,并且假设您的数据位于C:\\ Data.csv中,则[未测试]
for /f "tokens=1,2 delims=," %%a in ('type "C:\Data.csv"') do (net user %%a 123 /ADD & net localgroup %%b %%a /ADD)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.