Hi,
I have following tasks and currently I am able to perform required tasks using PowerShell as:
PowerShell >
Rename-LocalUser -Name LocalAdmin -NewName LAdmin -ErrorAction SilentlyContinue
Following code I am using but desired action isn't performed by the code, no errors either.
Dim p As Process = New Process()
p.StartInfo.FileName = "PowerShell.exe"
p.StartInfo.Arguments = "Rename-LocalUser -Name LocalAdmin -NewName LAdmin -ErrorAction SilentlyContinue -windowstyle hidden "
p.StartInfo.UseShellExecute = False
p.StartInfo.CreateNoWindow = True
p.StartInfo.RedirectStandardError = True
p.Start()
p.WaitForExit()
Dim sStdErr_psRename As String = p.StandardError.ReadToEnd()
Console.WriteLine("Exit code : {0}", p.ExitCode)
Console.WriteLine("StdErr : {0}", sStdErr_psRename)
Another task that I am currently performing using CMD is to change the password from command line as:
net user %UserName% NewPassword
But same as above, following code didn't performed desired task:
Dim cUsrPsw As Process = New Process()
cUsrPsw.StartInfo.FileName = "net.exe"
cUsrPsw.StartInfo.Arguments = "user %UserName% NewPassword"
cUsrPsw.StartInfo.UseShellExecute = False
cUsrPsw.StartInfo.CreateNoWindow = True
cUsrPsw.StartInfo.RedirectStandardError = True
cUsrPsw.Start()
cUsrPsw.WaitForExit()
Dim sStdErr_cUsrPsw As String = cUsrPsw.StandardError.ReadToEnd()
Console.WriteLine("Exit code : {0}", cUsrPsw.ExitCode)
Console.WriteLine("StdErr : {0}", sStdErr_cUsrPsw)