Jump to content

VBScript to create local user


JoshN

Recommended Posts

OK, needing a little bit o' help here. I'm wanting to create a vbscript that creates a local administrative user on an XP Pro computer already joined to an NT4 domain. The script prompts for the username that needs to be created. Here's what I have so far, from gleaning here and there:

result1 = inputbox ("Please type the name of the new user", "user name",,800,800)strComputer = "."Set colAccounts = GetObject("WinNT://" & strComputer & ",computer")Set objUser = colAccounts.Create("Administrators", result1)objUser.SetPassword ""objUser.SetInfo

I kinda figured this wouldn't run, but when run, I get "One or more arguments are invalid" error on line 4, character 1. I really don't need the password line, since the password is already set in the domain.Can anyone tell me what needs to happen here to get this to work? I'm not at all proficient at vbscripting, so take it easy one me.As a side question, when creating a new local user on a computer joined to a domain (in XP), it asks for a domain for that user. Would that need to be added to the script?EDIT: The user that will be added to the computer is a domain user that has already been created.

Link to comment
Share on other sites

Hmm.. Pretty dumb on my part seeing how I don't use XP and I'm not very familar with vbscripting on the platforms, but doesn't Administrator already exist from the start when XP is installed? All of the versions that I have worked with appear to have it. Try [Ctrl] + [Alt] + [Del], Type Administrator for User Name. Unfortunately, you'll have to find out what the password really is from the person who set it up or try a blank password the first time around.

Link to comment
Share on other sites

Try [Ctrl] + [Alt] + [Del], Type Administrator for User Name.
?? Where exactly do you type that? C+A+D brings up the Windows Task Manager on my XP system not the logon window.
Link to comment
Share on other sites

Hmm.. Pretty dumb on my part seeing how I don't use XP and I'm not very familar with vbscripting on the platforms, but doesn't Administrator already exist from the start when XP is installed? All of the versions that I have worked with appear to have it. Try [Ctrl] + [Alt] + [Del], Type Administrator for  User Name.  Unfortunately, you'll have to find out what the password really is from the person who set it up or try a blank password the first time around.
I am the person who sets these up and I know that there is already an Administrator account. I'm trying to create a user that already exists on the domain and add them to the local Administrators group.
Link to comment
Share on other sites

strComputer = "MyComputer"Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")Set objUser = GetObject("WinNT://" & strComputer & "/username,user")objGroup.Add(objUser.ADsPath)

Link to comment
Share on other sites

Change the User PasswordSet objUser = GetObject _("LDAP://cn=username,ou=management,dc=fabrikam,dc=com")objUser.ChangePassword "i5A2sj*!", "jl3R86df"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...