I deployed a bunch of new computers to a network using terminal services. Since the real authentication is at the server we standardize the local computer login to the username user1 and the password user1, just to keep things simple.  So I needed a easy way to create this account locally on 30+ workstations. Here is what I came up with:
Option Explicit
‘ On Error Resume Next
Dim objComputer, objGroup, objUser, objWSHNetwork, strComputerName, FullName, Password, UserName, lngFlag
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
Const ADS_UF_PASSWD_CANT_CHANGE = &H40
Set objWSHNetwork = WScript.CreateObject(“WScript.Network”)
strComputerName = objWSHNetwork.ComputerName
Set objComputer = GetObject(“WinNT://” & strComputerName)
Set objGroup = GetObject(“WinNT://” & strComputerName & “/Users”)
UserName = “user1”
FullName = “user1”
Password = “user1”
Set objUser = objComputer.Create(“User“, UserName)
objUser.SetPassword Password
objUser.FullName = FullName
objUser.SetInfo
objGroup.Add “WinNT://” & strComputerName & “/” & UserName
lngFlag = objUser.Get(“UserFlags”)
lngFlag = lngFlag Or ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put “UserFlags”, lngFlag
lngFlag = objUser.Get(“UserFlags”)
lngFlag = lngFlag Or ADS_UF_PASSWD_CANT_CHANGE
objUser.Put “UserFlags”, lngFlag
objUser.SetInfo
objUser.SetInfo
What this does is it creats a user account on the local computer feel free to change the red values to fit your needs. Â It also flags the password as user cannot change and never expires. Â These sections of code (marked in purple) can be removed to fit your needs. Â Remember visual basic scripts are hangled by wscript.exe usually found in c:windowssystem32wscript.exe. Be sure to point the script to this if you are using it as a login script or pusing it through a third party application like kaseya.
here is a example of this being used in kaseya, copy the script, edit it to your needs, save it as user1.vbs, adn put it on the kaseya server. Run it an vola, user account across a network.
Script Description: Creats an account called user1 with the password user1 and sets it to never expire and user cannot change. Â
IF True
THEN
Write File
Parameter 1 : c:tempuser1.vbs
Parameter 2 : adminVBSadmin.vbs
OS Type : 0
Execute File
Parameter 1 : c:WINDOWSsystem32wscript.exe
Parameter 2 : c:tempuser1.vbs
Parameter 3 : 3
OS Type : 0
ELSE
Hope this helps, it took me a while to develop.
#1 by Hoppy on January 13, 2010 - 9:35 pm
Hey thanks, great solution!
I couldn’t get my vbs script to execute on the Kaseya client, I was missing the call to wscript.exe, all good now.
Cheers,
Ghoppy