Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Create user with vb script

- - - - -

  • Please log in to reply
1 reply to this topic

#1
targa

targa

    Newbie

  • Member
  • 27 posts
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


How to remove advertisement from MSFN

#2
gunsmokingman

gunsmokingman

    MSFN Master

  • Super Moderator
  • 2,418 posts
  • OS:none specified
  • Country: Country Flag
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




GunSmokingMan






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN