Exec

sjesweak

Member
Joined
Feb 1, 2004
Messages
5
Is there anything in the .NET Framework that worked like the exec family in C and if so does anyone have any examples on it?
 
ok great thx .. i never thought to look in the diagnostic area hehe. What would you use if you have to supply a password to the command prompt after running an application with this... such as with the runas command?
 
Originally posted by sjesweak
ok great thx .. i never thought to look in the diagnostic area hehe. What would you use if you have to supply a password to the command prompt after running an application with this... such as with the runas command?

SendKeys and Win32Window.

Use Win32Window to find the command prompt window, and then use SendKeys to supply the username and password.
 
You could also use the stream redirection provided by the process class.
Code:
Dim pi As New ProcessStartInfo("file name")
pi.RedirectStandardInput = True redirect the input to a stream you can write to
pi.UseShellExecute = False required statement to use stream redirection
Dim pr As Process = ProcessStart(pi) start the process using the process start info we created earlier
dim sw As Io.StreamWriter = pr.StandardInput
You can write to the stream now and the console window will receive the input (the input will not be shown on the console window).
 
Originally posted by mutant
You could also use the stream redirection provided by the process class.
Code:
Dim pi As New ProcessStartInfo("file name")
pi.RedirectStandardInput = True redirect the input to a stream you can write to
pi.UseShellExecute = False required statement to use stream redirection
Dim pr As Process = ProcessStart(pi) start the process using the process start info we created earlier
dim sw As Io.StreamWriter = pr.StandardInput
You can write to the stream now and the console window will receive the input (the input will not be shown on the console window).

much cleaner, very nice.
 
Back
Top