stev379
Guest
|
Posted:
Sun Jan 09, 2005 8:49 am Post subject:
Add local user to admin's group |
|
|
Hi.
The script to add a local user to the admin group below is erroring on
objGroup.add(user) with "Type mismatch". Where have I gone wrong? The user
account exists and is created via another vbs script. I did notice that upon
account creation, it's properties on the "member of" tab don't show the
account even being a member of the users group. There is nothing listed
under this tab.
'Script that errors
strComputer = "."
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/TEST,user")
objGroup.Add(objUser)
'end script
------------------------------------------------------
'Script that creates the account...With or w/o the strPW variable...same
results
strComputer = "."
strPW = InputBox("Please enter a new password," & chr(13) & _
"and click OK.")
Set objShell = createobject("wscript.Shell")
Set colAccounts = GetObject("WinNT://" & strComputer & ",computer")
Set objUser = colAccounts.Create("user", "TEST")
objUser.SetPassword strPW
objUser.SetInfo
'End script
Thanks for any help or suggestions!
-Steve |
|
Torgeir Bakken (MVP)
Guest
|
Posted:
Mon Jan 10, 2005 5:08 pm Post subject:
Re: Add local user to admin's group |
|
|
stev379 wrote:
| Quote: | Hi.
The script to add a local user to the admin group below is erroring on
objGroup.add(user) with "Type mismatch". Where have I gone wrong? The user
account exists and is created via another vbs script. I did notice that upon
account creation, it's properties on the "member of" tab don't show the
account even being a member of the users group. There is nothing listed
under this tab.
'Script that errors
strComputer = "."
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/TEST,user")
objGroup.Add(objUser)
Hi |
Try
objGroup.Add(objUser.ADsPath)
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx |
|