Question need to run executable file with parameter

kim_ray

New member
Joined
Aug 4, 2011
Messages
2
Programming Experience
Beginner
hi,

i need to run a dos command with parameter and write out on text file from my win form , i am not using shell command and the code is -

Dim sourceName As String = "D:\doc\x\info.txt"
Dim targetName As String = "D:\doc\x\text.txt"
Dim fName As String = "D:\doc\x\md5.exe"

Dim p As New ProcessStartInfo
p.FileName = fName
p.Arguments = targetName & " > " & sourceName
p.WindowStyle = ProcessWindowStyle.Hidden
Process.Start(p)

but this is not working plz suggest me
 
Redirect the output by setting RedirectStandardOutput property to True, also set UseShellExecute property to False first. For Arguments property leave out the DOS redirect.
Then get StandardOutput (a StreamReader) from the process instance and write the output to a file, for example:
Dim pcs = Process.Start(p)
IO.File.WriteAllText(sourceName, pcs.StandardOutput.ReadToEnd)

(didn't you mix up source and target by the way? semantically one get from a source and put to a target)
 
Back
Top