Problems With User Creation Script

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Problems With User Creation Script
# 1  
Old 01-07-2013
Problems With User Creation Script

Hello everyone,

I've been attempting to make a program which creates user accounts from a file which contains the usernames required. It also checks if the directory of the username exists in the C:\Users directory and then is going to give the option to delete the directory, or rename it, this is the code I have so far (not finished, using echo's for test purposes):
Code:
@ECHO OFF
GOTO USERADD

:USERADD 
	FOR /F %%i IN (C:\Users\Charlie\Documents\Usernames.txt) DO IF EXIST C:\Users\%%i (
											    SET /P deleteorkeep="This username %%i already exists, press d to delete the account and files, press k to delete the account but rename the files folder with a suffix of _old:" 
										            
											    IF /i "%deleteorkeep:~,1%" EQU "d" (
											     	ECHO delete
											   )

											    IF /i "%deleteorkeep:~,1%" EQU "k" (
												ECHO keep
											   ) ELSE (
											      NET USER %%i %%i /add
											   )
)

The problem I'm having is that when I type either 'k' or 'd' the echo output is often incorrect (the script echo's keep, when I've pressed d). I have no idea what the problem is as I'm relatively new to batch scripting, so I need someone's help!

Thanks in advance
# 2  
Old 01-28-2013
it is a problem of parenthesis positionning :
Code:
@echo off
 SET /P deleteorkeep="This username %%i already exists, press d to delete the account and files, press k to delete the account but rename the files folder with a suffix of _old:" 
IF /i "%deleteorkeep:~,1%" EQU "d" (      ECHO delete    )
   IF /i "%deleteorkeep:~,1%" EQU "k" (   ECHO keep     
   ) ELSE (     
   NET USER %%i %%i /add     )

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for user account Creation

Hi Folks, I had a request to create the user request. Between, I just write a script a create, Update Geos, and update the password. My script as below: The error message, what I am getting is all the users are updated with the same Goes value.. #!/bin/bash for i in `cat users.txt`;do... (2 Replies)
Discussion started by: gsiva
2 Replies

2. AIX

PowerVM/lpar creation problems

Hi, I'm a newbie to PowerVM and LPARs ( I work with VmWare and Oracle VM Server for Sparc) .recently we purchased an 8202-e4b server, with two enclosures for add'l disk capacity. it is licensed for PowerVM standard,came preloaded as such, AIX 7.1. I've set up HMC v8.2, and run it through a VM on... (30 Replies)
Discussion started by: computron
30 Replies

3. Shell Programming and Scripting

Bash shell script for user creation in solaris

Hi All, I am new to shell scripting and have a task which need to be completed ASAP. I have searched all the forum and couln't find excat script which could run on solaris.can someone give me the fully working script for below. Bash shell script to create user account with paraments as... (1 Reply)
Discussion started by: sintilash
1 Replies

4. Solaris

Package creation problems with Source files

Hi, I am creating "LSOF" solaris package from solaris "source" files. I have compiled the source file and with that i created prototype file also. Then using pkgmk command i can make the package . In the package i am having (pkginfo pkgmap reloc) two file and one directory respectively But... (3 Replies)
Discussion started by: Kathirvel G
3 Replies

5. UNIX for Advanced & Expert Users

Can we Automate the User creation and setting password through a script in solaris 10

Hi, I am using Solaris 10 OS and Bash shell.Is there any way can we automate User creation and setting passwords through a script or any freeware tool. Advance thanks for your response. (1 Reply)
Discussion started by: muraliinfy04
1 Replies

6. Shell Programming and Scripting

User creation script

Hi Gems.. I am working out on project of creating a mass user on 100 server. Please help me with script where i can create an user id of new 80 user using shell script Thanks in advance. Indrajit Bhagat (1 Reply)
Discussion started by: indrajit_renu
1 Replies

7. Solaris

Need help with user creation

Hello guys, i have a problem where i cant create a user and here some problem that i encounter. 1. /etc/passwd seems locked. 2. getting this error UX: useradd: ERROR: Cannot update system files - login cannot be created. # useradd -u 47367 -g 1084 -c "user123" -d /local/home/user123 -s... (2 Replies)
Discussion started by: brew
2 Replies

8. Shell Programming and Scripting

Help in Shell scripting to modify the User Creation script in oracle database.

Hi, I have several users to create on my test Oracle database taking the scripts from the Production Oracle database. I have a separate text file where I have user-id and passwords maintained. I need help in writing a shell script to go thru the user creation scripts and replace VALUES... (1 Reply)
Discussion started by: rparavastu
1 Replies

9. Solaris

User creation

Hi all, I want to create one user with full permissions to one directory called /opt/tivoli/tsm/client/ba/bin. Name for the user Tivoli Thanks & Regards Babu (7 Replies)
Discussion started by: lbreddy
7 Replies

10. Shell Programming and Scripting

user creation using shell script for JSP

hello friends, I have problem. We want to create user from jsp(browser based) on our linux server. How we can do that ? or How do we create a user with shell programming by taking arguments and checking with the existing users and if the user exist it should display the message the user exists... (1 Reply)
Discussion started by: jarkvarma
1 Replies
Login or Register to Ask a Question