Script to add domain user account to local Administrators group

This VB Script adds a domain user account

WEBINAR: On-demand webcast

Next-Generation Applications Require the Power and Performance of Next-Generation Workstations REGISTER >

Want to share a script? Click here to contribute!

Rod Trent - rtrent [at] swynk [dot] com

Windows NT (with WSH 2.0 from and WMI 1.1 from
Windows 2000


This VB Script adds a domain user account to the local machine's administrators group. There are two variables that need to be changed in the script to match the organization. The first is the DomainName variable, and the second is the UserAccount variable. Save as a .VBS script and run with CScript.

Scroll down to view the script.

Script to add domain user account to local Administrators group

Dim DomainName
Dim UserAccount
Set net = WScript.CreateObject("WScript.Network")
local = net.ComputerName
DomainName = "DomainName"
UserAccount = "userAccount"

set group = GetObject("WinNT://"& local &"/Administrators")

on error resume next
group.Add "WinNT://"& DomainName &"/"& UserAccount &""

sub CheckError
	if not err.number=0 then
	set ole = CreateObject("ole.err")
	MsgBox ole.oleError(err.Number), vbCritical
	MsgBox "Done."
end if
end sub

Disclaimer: We hope that the information in these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by me. I shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

0 Comments (click to add your comment)
Comment and Contribute


(Maximum characters: 1200). You have characters left.



IT Management Daily
Don't miss an article. Subscribe to our newsletter below.