How to create users on Windows using python? Maybe Windows Batch?

I'm trying to create a script capable of of adding users on a Windows 7 operating system using python or Windows Batch. If its in another language, then that's fine to. I want the script to ask what the name should be for the user and and ask for a password to be created for the new user. Thanks!
Anthony RedgraveAsked:
Who is Participating?
NVITConnect With a Mentor Commented:
Using windows batch. Make a .bat file of this:

@echo off

set /p usrname=Enter username: 
if "%usrname%" equ "" exit /b
set /p pw=Enter password: 
if "%pw%" equ "" goto :GetPassword

net user %usrname% %pw%  /add
goto :AddUser

Open in new window

Anthony RedgraveAuthor Commented:
Thank You!!!!!
To add the same principle in Python (no checking...)

import subprocess

username = input('Enter username: ')
password = input('Enter password: ')'net user {} {} /add'.format(username, password))

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.