So ive been trying to use VB.Net to open a program with parameters, it works fine when i use a shortcut but i just cant get it to work 开发者_如何学Gowith VB.Net i think it has something to do with a parameter like this "--user=test".
Heres the arguments and ive already tried using String.Format()
Dim CMD As New Process
CMD.StartInfo.FileName = "C:\test.exe"
CMD.StartInfo.Arguments = "--user=test --pass=test -o test -p 1025 -d0 --verbose -f 60"
CMD.StartInfo.UseShellExecute = False
CMD.StartInfo.RedirectStandardInput = True
CMD.StartInfo.RedirectStandardOutput = True
CMD.StartInfo.CreateNoWindow = False
CMD.Start()
any ideas?
Try this, retval will be the output from the commands echo's to the console. I presume you want to capture this as you're redirecting std out:
Dim CMD As New Process
CMD.StartInfo.FileName = "C:\test.exe"
CMD.StartInfo.Arguments = "--user=test --pass=test -o test -p 1025 -d0 --verbose -f 60"
CMD.StartInfo.UseShellExecute = False
CMD.StartInfo.RedirectStandardInput = True
CMD.StartInfo.RedirectStandardOutput = True
CMD.StartInfo.CreateNoWindow = True
CMD.Start()
Dim retval As String = CMD.StandardOutput.ReadToEnd
CMD.WaitForExit()
Instantiate your process like this:
Dim myProcess As New System.Diagnostics.Process()
not like:
Dim myProcess As New Process()
It will work.
精彩评论