V
Vittorio Pavesi
Hello,
I'm trying to execute RunAs but I'm experiencing problem with standardinput;
it seems that the process doesn't receive it.
Here is the code, any help ?
Public Sub ActivateRunAs(ByVal AppPath As String, ByVal Username As
String, ByVal Password As String)
Dim RunAsPath As String =
System.Environment.GetEnvironmentVariable("SystemRoot") &
"\system32\runas.exe"
Dim Arg = " /user:" & Username & " " & AppPath & " "
Dim InputString As String
Dim p As New Process
p.StartInfo.FileName = RunAsPath
p.EnableRaisingEvents = True
p.StartInfo.Arguments = Arg
p.StartInfo.UseShellExecute = False
p.Start()
p.StartInfo.RedirectStandardInput = True
p.StandardInput.WriteLine(Password)
End Sub
I also tried with the following code, but it doesn't work.
p.StandardInput.BaseStream.Write(System.Text.Encoding.Unicode.GetBytes(Passw
ord), 0, Password.Length)
I'm trying to execute RunAs but I'm experiencing problem with standardinput;
it seems that the process doesn't receive it.
Here is the code, any help ?
Public Sub ActivateRunAs(ByVal AppPath As String, ByVal Username As
String, ByVal Password As String)
Dim RunAsPath As String =
System.Environment.GetEnvironmentVariable("SystemRoot") &
"\system32\runas.exe"
Dim Arg = " /user:" & Username & " " & AppPath & " "
Dim InputString As String
Dim p As New Process
p.StartInfo.FileName = RunAsPath
p.EnableRaisingEvents = True
p.StartInfo.Arguments = Arg
p.StartInfo.UseShellExecute = False
p.Start()
p.StartInfo.RedirectStandardInput = True
p.StandardInput.WriteLine(Password)
End Sub
I also tried with the following code, but it doesn't work.
p.StandardInput.BaseStream.Write(System.Text.Encoding.Unicode.GetBytes(Passw
ord), 0, Password.Length)