Script to set Local Admin

typhoon43

2[H]4U
Joined
Apr 5, 2001
Messages
3,930
Hey guys,
I have a new operator that I want to be able to unload some of my PC deployments to. I need him to be local admin on all machines in the Domain. I know there is a VB script that can be run as a login script that can do this for me, but I can't seem to hunt it down. Anyone know what I'm talking about?
Thanks
 
Nevermind, found it. For future reference here is the code
Code:
Dim DomainName 
Dim UserAccount 
Set net = WScript.CreateObject("WScript.Network") 
local = net.ComputerName 
DomainName = "yourdomainname" 
UserAccount = "useryouwantforadmin" 
set group = GetObject("WinNT://"& local &"/Administrators") 
on error resume next 
group.Add "WinNT://"& DomainName &"/"& UserAccount &"" 
CheckError 
sub CheckError 
if not err.number=0 then 
	set ole = CreateObject("ole.err") 
	'MsgBox ole.oleError(err.Number), vbCritical err.clear 
else 
	MsgBox "Yo, you are now the big dog on this machine." 
end if 
end sub

Hope this helps someone as much as it helped me
 
Back
Top