Results 1 to 4 of 4

Thread: Add users to local admin via login script

  1. #1
    Join Date
    Feb 2006
    Posts
    176

    Add users to local admin via login script

    Can anyone tell me whether it is possible to add the user logging into the local admin group of the box? Thanks for any information.

  2. #2
    Join Date
    Nov 2005
    Posts
    625

    Re: Add users to local admin via login script

    I think that you can try to run a Startup Script to do that. Or else you can use a Group Policy to setup a local Restricted Group. The trick to do this is to setup the GPO while using the tools (GPEdit or GP Management) on a Windows XP machine or a Windows 2000 non-dc machine.

  3. #3
    Join Date
    Sep 2005
    Posts
    2,327

    Re: Add users to local admin via login script

    There might be complication where the startup script will not know who the user will be. So, it should add a domain group to the local Admin group, and then all the desired users can be made members of this domain group. You have to use the group called Domain Users if you want everyone included. But a normal user will not be able to add themselves to any group, so a logon script will never work. Check the below VBScript where I add the domain group "MyGroup" to the local Administrators group

    Code:
    Option Explicit
    
    Dim strDomain, objNetwork, strComputer
    Dim objLocalGroup, objDomainGroup
    
    ' Specify the NetBIOS name of the domain.
    strDomain = "MyDomain"
    
    ' Retrieve NetBIOS name of local computer.
    Set objNetwork = CreateObject("Wscript.Network")
    strComputer = objNetwork.ComputerName
    
    ' Bind to local Administrators group.
    Set objLocalGroup = GetObject("WinNT://" & strComputer _
    & "/Administrators,group")
    
    ' Bind to domain group.
    Set objDomainGroup = GetObject("WinNT://" & strDomain & "/MyGroup,group")
    
    ' Check if the domain group is already a member of the local group.
    If Not objLocalGroup.IsMember(objDomainGroup.AdsPath) Then
    ' Add the domain group to the local group.
    objLocalGroup.Add(objDomainGroup.AdsPath)
    End If
    
    ' Clean up.
    Set objNetwork = Nothing
    Set objLocalGroup = Nothing
    Set objDomainGroup = Nothing

  4. #4
    Join Date
    Nov 2005
    Posts
    631
    You can try to use the runasspc.exe. It is normally a run as tool with environment variables and password encryption. You can call Script over runasspc.exe and add in the program options of runasspc the option %username%. After that you can get the current username in your script to add him to a local admin account.

Similar Threads

  1. adding domain users automatically to the local admin group
    By The Shadow in forum Active Directory
    Replies: 3
    Last Post: 07-06-2011, 10:57 PM
  2. Granting Domain Users Local Admin Rights
    By Jasonholt in forum Windows Security
    Replies: 2
    Last Post: 22-04-2009, 10:29 PM
  3. Local Admin Password change script for Domain PC's
    By Dharitree in forum Window 2000 Help
    Replies: 3
    Last Post: 13-10-2008, 09:32 AM
  4. can't add users to the local admin group
    By ride1600@cox.net in forum Windows Server Help
    Replies: 5
    Last Post: 07-07-2008, 06:37 PM
  5. script to add multple users to local admin group on servers
    By tdubb in forum Windows Server Help
    Replies: 1
    Last Post: 21-03-2008, 05:16 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,656,933,813.76846 seconds with 16 queries