[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2016-08-27
3
Medium Priority
?
146 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 25

Accepted Solution

by:
NVIT earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

650 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