• 0

Using Script on Local Accounts Question


Question

We use the code below to create a user from a program we built. All variables are declared of course. It works great - first creating the user and then adding that user into the proper group. However, is there a way to set the password to be non-expiring right when the user is created? Are there a couple of lines of script I can add that will set this flag? This code creates local users on a machine.

objWshNet = CreateObject("WScript.Network")

strComputer = objWshNet.ComputerName

colAccounts = GetObject("WinNT://" & strComputer & ",computer")

objUser = colAccounts.Create("user", sUserName)

objUser.SetPassword(sPassword)

objUser.SetInfo()

objGroup = GetObject("WinNT://" & strComputer & "/xfer_users,group")

objGroup.Add(objUser.ADsPath)

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I know you can do this on the command line like this (maybe u can use that by executing this from your script; i'm sure there's an 'exec' or similar function):

net user "Username" /EXPIRE:NEVER

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.