Solved

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

Posted on 2007-12-03
6
732 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
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

0
 

Author Comment

by:Manfredtoo
ID: 20401130
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
ID: 20401223
Does the user who is running this script have admin credentials?

regards
Chandru
0
Industry Leaders: 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!

 

Author Comment

by:Manfredtoo
ID: 20401358
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
ID: 20402139
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
ID: 20402942
Thanks Manfredtoo!
0

Featured Post

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

Suggested Solutions

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to count occurrences of each item in an array.

730 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