I'm working on a common utility install script for my clients that, among other things, creates a new user with admin privileges. My .cmd script works perfectly as far as it goes but... 1) it doesn't set the password expiration flag and 2) it's not very attractive. So, I'm trying to figure out the best way to do it with VBScript. Here's what I've cobbled together so far:
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
strComputer = "."
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", "TestUser")
objPasswordExpirationFlag = ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
set objGroup = Nothing
I'm obviously just learning vbs and don't full understand what I've put together or whether or not it will do what is needed which is:
Run on any XP, Vista or Win7 machine;
Create a new user with administrative privileges whose password won't expire; and
Done most efficiently with NO unintended consequences!
Note: The last item is of great concern so advice and explanations from those with experience will be most appreciated.