开发者

Using a windows batch file to create local users?

开发者 https://www.devze.com 2023-04-04 19:40 出处:网络
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 localg

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

精彩评论

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