Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 



Sign in to follow this  
targa

Create user with vb script

Recommended Posts

targa    0

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

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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×