Adding an user to a remote localgroup by scripting

G

Guest

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.
 
G

Guest

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.
 
L

Lanwench [MVP - Exchange]

In
pnunbe said:
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.
 
G

Guest

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.
 
L

Lanwench [MVP - Exchange]

In
pnunbe said:
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.

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top