• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 740
  • Last Modified:

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

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
Manfredtoo
Asked:
Manfredtoo
  • 3
  • 2
1 Solution
 
weellioCommented:

strComputer = "mycomputername"
strPeople = inputbox("what userid?",,"domain\userid")
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
Set objUser = GetObject("WinNT://" & strPeople)

Open in new window

0
 
ManfredtooAuthor Commented:
weellio: hiya thanks for yr fast responds, but it seems like not working. it didnt pop out any error message.
0
 
chandru_solCommented:
Does the user who is running this script have admin credentials?

regards
Chandru
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ManfredtooAuthor Commented:
chandru: hiya i am using an account with admin credentials. but its still working
0
 
chandru_solCommented:
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
 
chandru_solCommented:
Thanks Manfredtoo!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now