Home All Groups Group Topic Archive Search About

Adding an user to a remote localgroup by scripting

Author
25 Sep 2006 8:26 AM
pnunbe
I am running a small network made up of XP Pro computers (no domain).
I can add an user to a localgroup on a remote machine via the "Computer
management" console, but I could not find any way of accomplishing this task
through the NET command or scripting.
Any suggestion?
Thanks in advance.

Author
25 Sep 2006 12:44 PM
Lanwench [MVP - Exchange]
In news:AE1D1272-9E44-4BE8-A3DA-13446D94E0C1@microsoft.com,
pnunbe <pnu***@discussions.microsoft.com> typed:
> I am running a small network made up of XP Pro computers (no domain).
> I can add an user to a localgroup on a remote machine via the
> "Computer management" console, but I could not find any way of
> accomplishing this task through the NET command or scripting.
> Any suggestion?
> Thanks in advance.

net localgroup ?

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_localgroup.mspx?mfr=true
Author
25 Sep 2006 4:01 PM
pnunbe
The URL you suggested does not explain how I can perform the operation on
another computer in the network when no domain controller is present.
Thanks anyhow.

Show quoteHide quote
"Lanwench [MVP - Exchange]" wrote:

> In news:AE1D1272-9E44-4BE8-A3DA-13446D94E0C1@microsoft.com,
> pnunbe <pnu***@discussions.microsoft.com> typed:
> > I am running a small network made up of XP Pro computers (no domain).
> > I can add an user to a localgroup on a remote machine via the
> > "Computer management" console, but I could not find any way of
> > accomplishing this task through the NET command or scripting.
> > Any suggestion?
> > Thanks in advance.
>
> net localgroup ?
>
> http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_localgroup.mspx?mfr=true
>
>
>
Author
26 Sep 2006 4:26 AM
Lanwench [MVP - Exchange]
In news:16CC9DF6-EDE5-4CF2-8C57-308BB8DE9E4F@microsoft.com,
pnunbe <pnu***@discussions.microsoft.com> typed:
> The URL you suggested does not explain how I can perform the
> operation on another computer in the network when no domain
> controller is present. Thanks anyhow.

You can use the command in a batch file - run it on each computer as a
startup script as you like.
Without a domain, a lot of things are painful - you don't get many options
for centralized admin.


Show quoteHide quote
>
> "Lanwench [MVP - Exchange]" wrote:
>
>> In news:AE1D1272-9E44-4BE8-A3DA-13446D94E0C1@microsoft.com,
>> pnunbe <pnu***@discussions.microsoft.com> typed:
>>> I am running a small network made up of XP Pro computers (no
>>> domain). I can add an user to a localgroup on a remote machine via
>>> the "Computer management" console, but I could not find any way of
>>> accomplishing this task through the NET command or scripting.
>>> Any suggestion?
>>> Thanks in advance.
>>
>> net localgroup ?
>>
>> http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_localgroup.mspx?mfr=true
Author
26 Sep 2006 10:56 AM
pnunbe
That's OK, but how do you explain that I can perform this task via the
'Computer management' console?
I also tried to use the NetLocalGroupAddMembers API in a VB6 program, but I
get error 1387 (ERROR_NO_SUCH_MEMBER).
Here is my code:

Declare Function NetLocalGroupAddMembers Lib "netapi32" (lpServer As Byte,
lpGroup As Byte, ByVal lLevel As Long, lpBuffer As Byte, ByVal totalentries
As Long) As Long

Private Sub Command1_Click()
Dim result As Integer
Dim group() As Byte
Dim Server() As Byte
Dim User() As Byte
Server = "\\P866" & vbNullChar
group = "P866\Prova" & vbNullChar
User = "P866\Silvia" & vbNullChar
result = NetLocalGroupAddMembers(Server(0), group(0), 3, User(0), 1)
If result <> 0 Then
MsgBox result
End If
End Sub

Sorry for pestering you, but I really need this capability.

Show quoteHide quote
"Lanwench [MVP - Exchange]" wrote:

> In news:16CC9DF6-EDE5-4CF2-8C57-308BB8DE9E4F@microsoft.com,
> pnunbe <pnu***@discussions.microsoft.com> typed:
> > The URL you suggested does not explain how I can perform the
> > operation on another computer in the network when no domain
> > controller is present. Thanks anyhow.
>
> You can use the command in a batch file - run it on each computer as a
> startup script as you like.
> Without a domain, a lot of things are painful - you don't get many options
> for centralized admin.
>
>
> >
> > "Lanwench [MVP - Exchange]" wrote:
> >
> >> In news:AE1D1272-9E44-4BE8-A3DA-13446D94E0C1@microsoft.com,
> >> pnunbe <pnu***@discussions.microsoft.com> typed:
> >>> I am running a small network made up of XP Pro computers (no
> >>> domain). I can add an user to a localgroup on a remote machine via
> >>> the "Computer management" console, but I could not find any way of
> >>> accomplishing this task through the NET command or scripting.
> >>> Any suggestion?
> >>> Thanks in advance.
> >>
> >> net localgroup ?
> >>
> >> http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_localgroup.mspx?mfr=true
>
>
>
>
Author
26 Sep 2006 12:39 PM
Lanwench [MVP - Exchange]
In news:E525824D-D6B8-4AC3-B77C-300B4EAECFC5@microsoft.com,
pnunbe <pnu***@discussions.microsoft.com> typed:
> That's OK, but how do you explain that I can perform this task via the
> 'Computer management' console?

I have no idea. I read your question as meaning you wanted to know how to
script the addition of a user to a local group, rather than using the
computer management MMC.


Show quoteHide quote
> I also tried to use the NetLocalGroupAddMembers API in a VB6 program,
> but I get error 1387 (ERROR_NO_SUCH_MEMBER).
> Here is my code:
>
> Declare Function NetLocalGroupAddMembers Lib "netapi32" (lpServer As
> Byte, lpGroup As Byte, ByVal lLevel As Long, lpBuffer As Byte, ByVal
> totalentries As Long) As Long
>
> Private Sub Command1_Click()
> Dim result As Integer
> Dim group() As Byte
> Dim Server() As Byte
> Dim User() As Byte
> Server = "\\P866" & vbNullChar
> group = "P866\Prova" & vbNullChar
> User = "P866\Silvia" & vbNullChar
> result = NetLocalGroupAddMembers(Server(0), group(0), 3, User(0), 1)
> If result <> 0 Then
> MsgBox result
> End If
> End Sub
>
> Sorry for pestering you, but I really need this capability.

Sorry I can't help further; I don't know how to do this in VB. This may not
be the best group for your question - you may wish to post in a VB group.
Good luck!



Show quoteHide quote
>
> "Lanwench [MVP - Exchange]" wrote:
>
>> In news:16CC9DF6-EDE5-4CF2-8C57-308BB8DE9E4F@microsoft.com,
>> pnunbe <pnu***@discussions.microsoft.com> typed:
>>> The URL you suggested does not explain how I can perform the
>>> operation on another computer in the network when no domain
>>> controller is present. Thanks anyhow.
>>
>> You can use the command in a batch file - run it on each computer as
>> a startup script as you like.
>> Without a domain, a lot of things are painful - you don't get many
>> options for centralized admin.
>>
>>
>>>
>>> "Lanwench [MVP - Exchange]" wrote:
>>>
>>>> In news:AE1D1272-9E44-4BE8-A3DA-13446D94E0C1@microsoft.com,
>>>> pnunbe <pnu***@discussions.microsoft.com> typed:
>>>>> I am running a small network made up of XP Pro computers (no
>>>>> domain). I can add an user to a localgroup on a remote machine via
>>>>> the "Computer management" console, but I could not find any way of
>>>>> accomplishing this task through the NET command or scripting.
>>>>> Any suggestion?
>>>>> Thanks in advance.
>>>>
>>>> net localgroup ?
>>>>
>>>> http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_localgroup.mspx?mfr=true