Solved

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

Posted on 2016-08-27
3
61 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 23

Accepted Solution

by:
NVIT earned 500 total points
Comment Utility
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
Comment Utility
Thank You!!!!!
0
 
LVL 28

Expert Comment

by:pepr
Comment Utility
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

Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Robocopy questions 45 115
Folder size tool 6 59
Problems with GPO Printer Deployment 19 21
Installing Git and chefdk via bat script 8 16
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now