Solved

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

Posted on 2016-08-27
3
115 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 29

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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