?
Solved

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

Posted on 2007-12-03
6
Medium Priority
?
736 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
PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

 

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 1000 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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

764 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