[gptalk] Re: Creating a local admin account

  • From: "Bean, Scott" <Scott.Bean@xxxxxxxxxxxxxxxxxx>
  • To: "'gptalk@xxxxxxxxxxxxx'" <gptalk@xxxxxxxxxxxxx>
  • Date: Tue, 4 Nov 2008 10:32:36 -0500

This should work.  Works on w2k3 (but should work on xp and 2000).  On vista it 
only adds the user but doesn't add them to the administrator group.  Also sets 
the password to never expire.  Copy and paste into notepad and save as .vbs

On Error Resume Next

'Input Box
strComputer = InputBox("Enter Computer Name or IP address")
                If strComputer = "" Then
                End If
strUser= InputBox("Enter a User Name")
                If strUser = "" Then
                End If
strPassword = InputBox("Enter a Password")
                If strPassword = "" Then
                End If
'Creating User
Set colAccounts = GetObject("WinNT://" & strComputer)
Set objUser = colAccounts.Create("user", strUser)
objUser.SetPassword strPassword

'Set Password to never expire
Set objUser=GetObject("WinNT://" & strComputer & "/" & strUser & ",User")
                objPasswordExpirationFlag = objUserFlags OR 
                objUser.Put "userFlags", objPasswordExpirationFlag

'Add user to Local Admin Group
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")

From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On 
Behalf Of Darren Mar-Elia
Sent: Tuesday, November 04, 2008 9:52 AM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Re: Creating a local admin account

If you have GP Preferences in place, you can use GP directly to do that with 
the local users and groups feature-you don't even need a script. However, if 
you don't, then, assuming how many machines you have, I would just do this 
remotely using a tool like PSExec and some simple command lines, like this:

net user joesmith password /add
net localgroup administrators joesmith /add


From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On 
Behalf Of Dowdle, Ian
Sent: Tuesday, November 04, 2008 3:20 AM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Creating a local admin account

I am not sure that this is the correct forum for this but here goes. Does 
anyone have a vbs script that will create a local user account and add that 
user to the local administrators group? Scripting is not my strong point!

Ian Dowdle
PC Operations Manager
School of Computing
University of Teesside

A positive attitude may not solve all your problems, but it will annoy enough 
people to make it worth the effort.

Other related posts: