Add local user to admin's group
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
Add local user to admin's group

 
Post new topic   Reply to topic    Windows Server Forum Index -> Programming
Author Message
stev379
Guest





Posted: Sun Jan 09, 2005 8:49 am    Post subject: Add local user to admin's group Reply with 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)
'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
Back to top
Torgeir Bakken (MVP)
Guest





Posted: Mon Jan 10, 2005 5:08 pm    Post subject: Re: Add local user to admin's group Reply with quote

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
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Programming All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB