Python reads CSV files to generate the system account doscommand BAT file

Source: Internet
Author: User

No technical content, just Archive

#! /Usr/bin/ENV Python #-*-coding: UTF-8-*-# @ author jinqinghua@gmail.com # @ version 2012-08-24import csvpassword = "XXXXX" group = "R & D users" file_csv = "user.csv" # company address book file transferred over, the main fields include email address, password, name, department, and title if _ name _ = '_ main _': reader = CSV. reader (open (file_csv) for mail, passwd, name, team, rank in Reader: username = Mail. replace ('@ ligoo.cn', ''); print" REM ", mail, passwd, name. decode ('utf-8'), tea M. decode ('utf-8') print 'net USER % S/Add/active: No/expires: Never/passwordchg: yes/fullname: "% s"/comment: "% s" '% (username, password, name, Team + ''+ rank) print 'net localgroup" % s "% S/add' % (group, username) print "done... python is great! "

Doscommand

Run the net help USER command in cmd to view details.

Active: No. You can change it to yes.

In addition, Windows 2003 does not support/logonpasswordchg: {Yes | no} to specify whether the user should change his/her password upon next login. Sorry.

Net help user the syntax of this command is: net user [username [Password | *] [Options] [/domain] username {password | *}/Add [Options] [/domain] username [/delete] [/Domain] username [/times: {times | all}]. Net user creates and modifies the user account on the computer. When used without switching, the user accounts of the computer are listed. User account information is stored in the user account database. The user name that can be added, deleted, modified, or viewed. The user account name can be up to 20 characters. Specify or change the user account password. The password length must match the minimum length set in the/minpwlen option of the Net accounts command. It can be 14 characters long. * Generate a password prompt. When you enter the password, the password is not displayed. /Domain: perform this operation on the domain controller of the current domain. /Add: Add a user account to the user account database. /Delete: delete a user account from the user account database. The options are as follows: Option description ----------------------------------------------------------------/active: {Yes | no} to activate or deactivate the account. If the account is inactive, its users cannot access the server. The default value is "yes ". /Comment: "text" provides descriptive comments about user accounts. Enclose the text in quotation marks. /Countrycode: NNN uses the country code of the operating system to execute the specified language file to display user help and error messages. The value 0 indicates the default country code. /Expires: {date | never} if a date is set, the account may expire. Never sets the account to no time limit. The deadline is in the format of month, day, or year. A month can be a number, spelling all letters, or abbreviated as three letters. The year can be a two-digit or four-digit number. Use a slash (/) (with no space left) to separate the parts of the date. /Fullname: "name" the full name of the user (instead of the user name ). This name is caused by a quote. /Homedir: pathname indicates the path set for the user's main directory. The path must exist. /Passwordchg: {Yes | no} specifies whether the user can change the password. The default value is "yes ". /Passwordreq: {Yes | no} specifies whether the user account must have a password. The default value is "yes ". /Logonpasswordchg: {Yes | no} specifies whether the user should change his/her password upon next login. The default value is "no ". /Profilepath [: path] sets the path for the user login configuration file. /Scriptpath: Specifies the path of the pathname User Logon script. /Times: {times | all} Logon Time. Time indicates the date [-date] [, date [-date], time [-time] [, time [-time], and the increment is limited to 1 hour. The date can be a complete spelling or abbreviation. The hour can be a 12-or 24-hour mark. For the 12-hour mark, use am, PM, A.M. Or p.m. All indicates that the user can log on all the time, and blank indicates that the user cannot log on. Use commas to separate dates and time. Use semicolons to separate multiple dates from time. /Usercomment: "text" allows the Administrator to add or change user comments for the account. /Workstations: {computername [,...] | *} lists up to 8 computers that can be used to log on to the network. If/workstations does not have a list or its list is *, you can log on to the network from any computer. NET Help Command | more: displays the Help content on one screen at a time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.