Solved

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

Posted on 2007-12-03
6
724 Views
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.
cheers
0
Comment
Question by:Manfredtoo
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:weellio
Comment Utility

strComputer = "mycomputername"

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

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

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

Open in new window

0
 

Author Comment

by:Manfredtoo
Comment Utility
weellio: hiya thanks for yr fast responds, but it seems like not working. it didnt pop out any error message.
0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
Does the user who is running this script have admin credentials?

regards
Chandru
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:Manfredtoo
Comment Utility
chandru: hiya i am using an account with admin credentials. but its still working
0
 
LVL 12

Accepted Solution

by:
chandru_sol earned 250 total points
Comment Utility
try this script...


regards
Chandru
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

objGroup.Add(objUser.ADsPath)

End If

Open in new window

0
 
LVL 12

Expert Comment

by:chandru_sol
Comment Utility
Thanks Manfredtoo!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found here: http://www.experts-exchang…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to count occurrences of each item in an array.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

16 Experts available now in Live!

Get 1:1 Help Now