title: Add domain user and group to local administrators
body: <p>I have a piece of VBS code that I have modified that basically adds a specified domain user and group to the PCs local Administrators group. It works fine on Windows 7, but not at all on Windows 8.</p>
  
  <pre><code>Call AddUserToGroup("./Administrators", "myDomain.net/NetworkAdminis")
  Call AddUserToGroup("./Administrators", "myDomain.net/Domain Admins")
  Call addDomainUser("myDomain", "myUserGroup")
  
  Sub AddUserToGroup(local, domain)
      On Error Resume Next
  
      Dim objLocalGroup
      Dim objDomainGroup
      Dim server
  
      For Each server in servers
          Set objLocalGroup = GetObject("WinNT://" &amp; local &amp; ",group")
          Set objDomainGroup = GetObject("WinNT://" &amp; domain &amp; ",group")
          With objLocalGroup
              .Add(objDomainGroup.AdsPath)
              .SetInfo
          End With            
      Next
  
      Set objLocalGroup = Nothing
      Set objDomainGroup = Nothing
  End Sub
  
  Sub addDomainUser(strDomain, strUser)
      Dim strComputer
      Dim objWshNet
      Dim objGroup
      Dim objUser
  
      Set objWshNet = CreateObject("WScript.Network")
      strComputer = objWshNet.ComputerName
      Set objGroup = GetObject("WinNT://" &amp; strComputer &amp; "/Administrators,group")
      Set objUser = GetObject("WinNT://" &amp; strDomain &amp; "/" &amp; strUser &amp; ",user")
      If Not objGroup.IsMember(objUser.ADsPath) Then
          objGroup.Add (objUser.ADsPath)
      End If
  
      Set objWshNet = Nothing
      Set objGroup = Nothing
      Set objUser = Nothing
  End Sub
  </code></pre>
  
  <p>I have debugged the code line by line using VBA's IDE and there seems to be no error condition firing. It executes all lines, but it is not adding the users and groups as it did with Windows 7 and below. The script is being run as local administrator.</p>