Solved

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

Posted on 2007-12-03
6
734 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
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 …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

691 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