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.