objADGroup2 = GetObject ("WinNT://"&strDomain&"/Domain Admins,group") failed at Windws 10 startup

超 邓 1 Reputation point

Hi Guys

I tried to add some local and domain group to local admins group via windows group policy -startup scripts, as below.

Set objGroup = GetObject("WinNT://"&strComputerName&"/Administrators,group")
Set objUser = GetObject("WinNT://"&strComputerName&"/BL_OSD,user")
Set objADGroup1 = GetObject ("WinNT://"&strDomain&"/PCAdmins,group")
Set objADGroup2 = GetObject ("WinNT://"&strDomain&"/Domain Admins,group")

If Not ObjGroup.IsMember(objUser.ADsPath) Then
End If
If Not objADGroup1.IsMember(objADGroup1.ADsPath) Then
End If
If Not objADGroup2.IsMember(objADGroup2.ADsPath) Then
End If

Then i found that the local account "BL_OSD" added to the local admins group. However failed to add the domain group.
I added some err handling script ,like err.number after the
"Set objADGroup2 = GetObject ("WinNT://"&strDomain&"/Domain Admins,group")"
and found the error number was "-2147024843", i googled the error number ,seems it means the network path was not found.

But if i manually run the script after user login, everything works as expect.
So i wondering the problem maybe due to network was ready when the scripts running at startup or anything else?
Kindly need your help


An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
1,983 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bill Stewart 176 Reputation points

    It is likely a timing issue, as you expect.

    I would recommend not using scripts but rather group policy preferences to manage local group memberships anyway.