Welcome to MSFN

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.


Sign in to follow this  
Followers 0
targa

Create user with vb script

2 posts in this topic

I am trying to write a script to create a new account after windows finishes to install... manged to do the following but would like that the script pops-up a window asking for the username and password rather than being written in the vb script. Any help please????

Option Explicit

' On Error Resume Next

Dim objComputer, objGroup, objUser, objWSHNetwork, strComputerName, strFullName, strPassword, strUserName

Set objWSHNetwork = WScript.CreateObject("WScript.Network")

strComputerName = objWSHNetwork.ComputerName

Set objComputer = GetObject("WinNT://" & strComputerName)

Set objGroup = GetObject("WinNT://" & strComputerName & "/Administrators")

strUserName = "username"

strFullName = "user2"

strPassword = "password"

Set objUser = objComputer.Create("User", strUserName)

objUser.SetPassword strPassword

objUser.FullName = strFullName

objUser.SetInfo

objGroup.Add "WinNT://" & strComputerName & "/" & strUserName

objUser.SetInfo

0

Share this post


Link to post
Share on other sites

Try this

Option Explicit
' On Error Resume Next
Dim objComputer, objGroup, objUser, objWSHNetwork, strComputerName, strFullName, strPassword, strUserName

Set objWSHNetwork = WScript.CreateObject("WScript.Network")
strComputerName = objWSHNetwork.ComputerName
Set objComputer = GetObject("WinNT://" & strComputerName)
Set objGroup = GetObject("WinNT://" & strComputerName & "/Administrators")

Dim Password, UserName

While UserName = ""
UserName = InputBox("Type In Your User Name")
Wend

While Password = ""
Password = InputBox("Type In Your Password")
Wend

strUserName = UserName
strFullName = "user2"
strPassword = Password

Set objUser = objComputer.Create("User", strUserName)
objUser.SetPassword strPassword
objUser.FullName = strFullName
objUser.SetInfo
objGroup.Add "WinNT://" & strComputerName & "/" & strUserName
objUser.SetInfo

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.