Right Radimus.

And I used RemoteExec, for both creating and adding the account to local admin gruop. But it did'nt work that all. No account was created and nothing to add to local admin gruop.

So what I did to make the hole thing work is to use benny's code for creating the account, and your secound part of RemoteExec to add it to local admin gruop:

[Code]

$Computer = "192.168.0.10"
$NewUser = "David"
$NewPassword = "passwd"
$Group = "Administrators"
$FullName = "David J"
$Domain = "Home"

CreateLocalUserAccount ($Computer,$Domain,$NewPassword,$NewUser,$FullName,$Group)

Function CreateLocalUserAccount ($Computer,$Domain,$NewPassword,$NewUser,$FullName,$Group)

$Accounts = GetObject("WinNT://" + $Domain + "/" + $Computer + ",Computer")
$User = $Accounts.Create("user", $NewUser)
$SetUserPassword = $User.ChangePassword("", $NewPassword)
$User.SetPassword ($NewPassword)
$User.Put ("FullName", $FullName)
$User.SetInfo

$nul = fnRemoteExec('cmd /c net localgroup administrators /add '+$NewUser,$computer)

EndFunction

Function fnRemoteExec($sCommand,Optional $sComputer,Optional $sUser,Optional $sPwd)
Dim $objLocator,$objSvc,$objSet
$objLocator = CreateObject("WbemScripting.SwbemLocator")
$objSvc = IIf($sComputer='',$objLocator.ConnectServer(),$objLocator.ConnectServer($sComputer,,$sUser,$sPwd))
If @ERROR Exit @ERROR EndIf
$objSet = $objSvc.Get("Win32_Process")
If @ERROR Exit @ERROR EndIf
$fnRemoteExec = $objSet.Create($sCommand)
Exit @ERROR
EndFunction




Well I used fnRemoteExec instead of RemoteExec.

This way both operations was succeded. So at last Im happy. It works fine, creating and adding the accout as it should.

Many thanx to u all.
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"