Hi all,
I'm trying to add users remotely to a Windows 2003 Standard using the command net.exe, but I just can't make it work. This is my code:
Dim p As New Process
p.StartInfo.UseShellExecute =
Falsep.StartInfo.RedirectStandardError =
Truep.StartInfo.RedirectStandardInput =
Truep.StartInfo.RedirectStandardOutput =
Truep.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
p.StartInfo.Arguments =
" user " & xUser & " " & xPass & " /ADD /ACTIVE:YES /EXPIRES:NEVER"p.StartInfo.WorkingDirectory =
"C:\windows\system32"p.StartInfo.FileName =
"net"p.Start()
Dim sr As IO.StreamReader = p.StandardOutput Dim sb As New System.Text.StringBuilder("") Dim sinput As String = "" Do Until sinput = "-1"sb.Append(sr.ReadLine() & ControlChars.CrLf)
sinput = sr.Read
Loopp.WaitForExit()
p.Close()
Return sb.ToString
it doesn't return anything, and user is not created.
If I change the following line, it returns perfectly the table of users:
p.StartInfo.Arguments = " users"
so what could the problem be
Thanks in advance.
George