PC Review
Forums
Newsgroups
Windows XP
Windows XP WMI
add user
Forums
Newsgroups
Windows XP
Windows XP WMI
add user
![]() |
add user |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Please give us help, we need use script add some domain user into many computer's local administrators group.
|
|
|
|
#2 |
|
Guest
Posts: n/a
|
HB wrote:
> Please give us help, we need use script add some domain user into > many computer's local administrators group. Hi If Active Directory domain: You could do it in a computer startup script (with a GPO) that runs as part of the boot up process (before the user logs in). It runs under the system context and has admin rights. Here is a vbscript for you as a starting point: '--------------------8<---------------------- Set oWshNet = CreateObject("WScript.Network") sUser = "fill in some some user name here" sNetBIOSDomain = oWshNet.UserDomain sComputer = oWshNet.ComputerName Set oGroup = GetObject("WinNT://" & sComputer & "/Administrators,group") Set oUser = GetObject("WinNT://" & sNetBIOSDomain & "/" & sUser & ",user") ' suppress errors in case the user is already a member On Error Resume Next oGroup.Add(oUser.ADsPath) On Error Goto 0 '--------------------8<---------------------- It will try to add the user name in the variable "sUser" to the "Administrators" group every time the computer boots up. If the user already exists, the error is suppressed. If the computers are in another domain than the user you want to add, you will need to hard code the domain name the user belongs to in the variable "sNetBIOSDomain". WSH 5.6 documentation (local help file) can be downloaded from here if you haven't got it already: http://msdn.microsoft.com/downloads/list/webdev.asp -- 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/sc...er/default.mspx |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

