开发者

Using a windows batch file to create local users?

I need to create a list of local users that are sequential on Windows Server 2003.

Using ServerFault I was able to find out the proper commands to a) create a user and b) assign that user to a localgroup.

My commands would be:

net user myUserName /random /add /comment:"9.13.2011" /expires:never /fullname:"My User Name" /passwordchg:no

Adding that user to 'Remote Desktop Users' group:

net localgroup "Remote Desktop Users" myUserName /add

The username would start at myUserName1 and would iterate up to myUserName100.

Is it possible to use a win开发者_如何学Pythondows batch (or cmd) file to iterate through these two commands to create my user list?


Are you looking for something like this?

set number=0

:start_loop
set /A number=%number%+1
if %number% GTR 100 goto end

net user myUserName%number% /random /add /comment:"9.13.2011" /expires:never /fullname:"My User Name %number%" /passwordchg:no
net localgroup "Remote Desktop Users" myUserName%number% /add

goto start_loop

:end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜