Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: add user and file directory in batch file?  (Read 4780 times)

0 Members and 1 Guest are viewing this topic.

yvonne

  • Guest
add user and file directory in batch file?
« on: April 13, 2005, 09:45:34 PM »
 I would like to know how to add a list of user from a file in batch file. and also how to add directory/file in using batch file?

thank you

gussery

  • Guest
Re: add user and file directory in batch file?
« Reply #1 on: April 14, 2005, 05:23:01 AM »
Add a user to what?
Local computer users?
Domain computer users?
Active Directory?
SQL Server?
Oracle?

yvonne

  • Guest
Re: add user and file directory in batch file?
« Reply #2 on: April 14, 2005, 05:48:21 AM »
add to active directory. Thanks

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: add user and file directory in batch file?
« Reply #3 on: April 14, 2005, 06:11:45 AM »
You need to write an ADSI script.

strContainer = ""
strName = "EzAdUser"

'***********************************************
'*         Connect to a container              *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
 Set objContainer = GetObject("LDAP://" & _
   objRootDSE.Get("defaultNamingContext"))
Else
 Set objContainer = GetObject("LDAP://" & strContainer & "," & _
   objRootDSE.Get("defaultNamingContext"))
End If
'***********************************************
'*       End connect to a container            *
'***********************************************

Set objUser = objContainer.Create("user", "cn=" & strName)
objUser.Put "sAMAccountName", strName
objUser.SetInfo


You have to make changes to the strContainer and strName variables. Save the file with a VBS extension and  run it from the Windows Run Box. Include the extension for execution. Feel free to configure the script to your needs.

Hope this helps.  8)
« Last Edit: April 14, 2005, 06:13:17 AM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

yvonne

  • Guest
Re: add user and file directory in batch file?
« Reply #4 on: April 14, 2005, 09:09:16 PM »
sorry, i can't get you. perhaps you can explain in a simple way. previously i thot i can write a .bat file and run it in dos prompt, which will be able to generate a set of user based on an input userlist file.

yvonne

  • Guest
Re: add user and file directory in batch file?
« Reply #5 on: April 15, 2005, 12:46:27 AM »
I understand that Dsadd utility found in windows 2003 can add a user to Active Directory (AD) from the command line without using a script?

what if i wan to create not one a single user, but a list of user which import from a file, can this command help me without using a script?

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: add user and file directory in batch file?
« Reply #6 on: April 15, 2005, 05:43:49 AM »
Oops, I really screwed this one up. You can use DSADD from the command line.

for /f %%i in (namefile.txt) do dsadd ...

%%i is a user name from your file
namefile.txt is the label of the file containing the names
... are the DSADD switches (there is boat load of them)

If you type DSADD /? at the prompt, you should get a list of all the switches, or try this site:

http://www.microsoft.com/windowsxp/home/using/productdoc/en/default.asp?url=/windowsxp/home/using/productdoc/en/dsadd_user.asp


Personally, I would use a script. It's much more powerful than batch language and was designed to automate these types of tasks.

Good luck.  8)
« Last Edit: April 15, 2005, 05:59:10 AM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein