Input box being prompt to add domain users into Local administrator group using VBScript

Posted on 2007-12-03
Last Modified: 2008-02-01
Hi Experts
I need some help to add a domain user into local administrator group while being prompted to key in a domain user into the input box using vbscript.
Question by:Manfredtoo
  • 3
  • 2
LVL 19

Expert Comment

ID: 20400989

strComputer = "mycomputername"

strPeople = inputbox("what userid?",,"domain\userid")

Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")

Set objUser = GetObject("WinNT://" & strPeople)

Open in new window


Author Comment

ID: 20401130
weellio: hiya thanks for yr fast responds, but it seems like not working. it didnt pop out any error message.
LVL 12

Expert Comment

ID: 20401223
Does the user who is running this script have admin credentials?

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.


Author Comment

ID: 20401358
chandru: hiya i am using an account with admin credentials. but its still working
LVL 12

Accepted Solution

chandru_sol earned 250 total points
ID: 20402139
try this script...

Set objWshNet = CreateObject("WScript.Network")

'  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'  // Configure basic script variables

strDomain = objWshNet.UserDomain

strComputer = objWshNet.ComputerName

Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")

'  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'  // Configure to add a domain user to the Local Administrators Group

strUser = Inputbox("Enter the name of the user","Username","")

Set objUser = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")

'  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'  // Configure to add a domain group to the Local Administrators Group

'strUser = "domaingrouphere'

'Set objUser = GetObject("WinNT://" & strDomain & "/" & strUser & ",group")

'  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'  // We actually add the user or group here, if not already a member of the local

'  // Administrators group:

If Not objGroup.IsMember(objUser.ADsPath) Then


End If

Open in new window

LVL 12

Expert Comment

ID: 20402942
Thanks Manfredtoo!

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now