We help IT Professionals succeed at work.

VB Script = Add User to the local Machine

2,390 Views
Last Modified: 2012-06-21
For some reason this script may be old.. Does the job when i add the computer to the local admin groups on the computer. But now each time the computer boots up, the script runs .. how can i hide the script giving the error message or adjust it that it works properly

I have this script as a startup script from my AD 2003 - basically adding the Administrator from the OU to the local admin acocunt on the computer.

Dim oGrpLocal
On Error Resume Next
Set oGrpLocal = GetObject ("WinNT://./administrators,group")
If err.Number <> 0 then
   WScript.Quit
End If
'The DOMAIN below is the netbios domain name, and OULocalAdmins is the name of the group you
'want to add to the local administrators group.
If Not oGrpLocal.IsMember("WinNT://DOMAIN/OULocalAdmins") Then
   oGrpLocal.Add "WinNT://DOMAIN/OULocalAdmins"
End If
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.