Link to home
Start Free TrialLog in
Avatar of The_Dark_Rabbit
The_Dark_Rabbit

asked on

Using WSH (VB) to add a domain user to local administrator's group under Windows XP/2003

Hi,

I'm working on a script that I want to be able to run on my admin station and do the following:

- Query user for a domain user account name (service account)
- For each workstation(XP) on a list, add that domain user to the local administrator's group

I've tried:
strComputer = [computer name variable]
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")

Set objUser = GetObject("WinNT://" & strComputer & "/" & [user name variable] & ",user")
objGroup.Add(objUser.ADsPath)

I also tried with:
Set objUser = GetObject("WinNT://" & strComputer & "/DOMAIN\" & [user name variable] & ",user")

I get a "Exception: Unknown Exception" error every time... I know that this is probably because I'm trying to change a domain account instead of a local account, but I can't find any info on how I would do this for a domain account.  Any suggestions?

And yes, the user executing the script has full administrative privilages  on the target machines.

And yes, I'm kind of new to programming this kind of script, why do you ask?

Cheers!
Avatar of Shiju S
Shiju S
Flag of United States of America image


Here is a fine source code
hope this will help you
http://vbnet.mvps.org/index.html?code/network/openuserbrowser.htm

Avatar of The_Dark_Rabbit
The_Dark_Rabbit

ASKER

Thanks for the quick response.  However, the code you pointed me to seems a little inpenetrable to me (as I mentioned, I'm a beginner).  I'm not sure which bits are useful to me.  If someone could help me find the bit I need on that page so that I can find a way to integrate it into my script (which actually does a few other tasks as well), then your link might be useful.  Otherwise, I'm looking for a quick piece of code, not a whole script.

Cheers,

TDR
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot, Chris!  That's exactly what I was looking for.  I feel kind of dumb for not figuring that one out, but I am grateful nonetheless.

Cheers,

TDR

Glad I could help :)

Chris