Solved

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

Posted on 2016-08-27
3
86 Views
Last Modified: 2016-08-28
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!
0
Comment
Question by:Anthony Redgrave
3 Comments
 
LVL 24

Accepted Solution

by:
NVIT earned 500 total points
ID: 41773334
Using windows batch. Make a .bat file of this:

@echo off
setlocal

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

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

Open in new window

0
 

Author Comment

by:Anthony Redgrave
ID: 41773412
Thank You!!!!!
0
 
LVL 28

Expert Comment

by:pepr
ID: 41774038
To add the same principle in Python (no checking...)
#!python3

import subprocess

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

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question