B
Ben Blackmore
Hi,
I'd like to add a user to a machines local administrator group, either via
group policy or a logon script. I found the following script on the net,
however it doesn't seem to work: -
Dim DomainName Dim UserAccount Set net =
WScript.CreateObject("WScript.Network") local = net.ComputerName DomainName
= "MyDomain" UserAccount = "UserAccount" set group = GetObject("WinNT://"&
local &"/Administrators") on error resume next group.Add "WinNT://"&
DomainName &"/"& UserAccount &"" CheckError sub CheckError if not
err.number=0 then set ole = CreateObject("ole.err") MsgBox
ole.oleError(err.Number), vbCritical err.clear else MsgBox "Done." end if
end sub
Can anyone see why its not working, or think of another way to add a user to
a local group. Ideally I'd like to be able to add %username% to any group,
so I don't have to keep changing the username by hand, it will just pick up
the current user who is logging on!
Cheers
Ben
I'd like to add a user to a machines local administrator group, either via
group policy or a logon script. I found the following script on the net,
however it doesn't seem to work: -
Dim DomainName Dim UserAccount Set net =
WScript.CreateObject("WScript.Network") local = net.ComputerName DomainName
= "MyDomain" UserAccount = "UserAccount" set group = GetObject("WinNT://"&
local &"/Administrators") on error resume next group.Add "WinNT://"&
DomainName &"/"& UserAccount &"" CheckError sub CheckError if not
err.number=0 then set ole = CreateObject("ole.err") MsgBox
ole.oleError(err.Number), vbCritical err.clear else MsgBox "Done." end if
end sub
Can anyone see why its not working, or think of another way to add a user to
a local group. Ideally I'd like to be able to add %username% to any group,
so I don't have to keep changing the username by hand, it will just pick up
the current user who is logging on!
Cheers
Ben