用于创建本地帐户并添加到管理员组的VBScript,用于在注销/登录之前测试新创建的帐户:

用于创建本地帐户并添加到管理员组的VBScript,用于在注销/登录之前测试新创建的帐户:,vbscript,Vbscript,唉。一个简单的“以管理员身份运行”问题 Set objShell = CreateObject("Wscript.Shell") Set objEnv = objShell.Environment("Process") strComputer = objEnv("COMPUTERNAME") strUser = inputbox("Enter the username for the new admin account.") strPass = inputbox("Enter the pass

唉。一个简单的“以管理员身份运行”问题

Set objShell = CreateObject("Wscript.Shell")

Set objEnv = objShell.Environment("Process")
strComputer = objEnv("COMPUTERNAME")
strUser = inputbox("Enter the username for the new admin account.")
strPass = inputbox("Enter the password for the new account.")

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

Set objUser = colAccounts.Create("user", strUser)

objUser.SetPassword strPass

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
objPasswordExpirationFlag = ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag

objUser.SetInfo 

Set Group = GetObject("WinNT://" & strComputer & "/Administrators,group")
Group.Add(objUser.ADspath)