【发布时间】:2013-01-02 06:12:10
【问题描述】:
在修复了大量错误后,我的代码终于可以正常工作了,但我仍然遇到了一些小问题
Dim myprocess As New System.Diagnostics.Process
myprocess.StartInfo.FileName = "cmd.exe"
myprocess.StartInfo.UseShellExecute = False
myprocess.StartInfo.RedirectStandardOutput = True
myprocess.StartInfo.RedirectStandardInput = True
myprocess.StartInfo.WorkingDirectory = "C:\"
myprocess.StartInfo.CreateNoWindow = True
myprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myprocess.Start()
myprocess.StandardInput.WriteLine(prompt.Text)
myprocess.StandardInput.Flush()
myprocess.StandardInput.Close()
prompt.Text = ""
prompt.Text = myprocess.StandardOutput.ReadToEnd
myprocess.StandardOutput.Dispose()
myprocess.StandardOutput.Close()
myprocess.WaitForExit()
myprocess.Close()
问题是,如果我执行诸如“TREE”之类的命令,它就无法解释构成树的行。执行“TREE /A”可以解决问题,但我想知道为什么不能正确解释普通的旧“TREE”。
另外,一旦我执行了诸如“TREE”之类的命令,我就无法在我的文本框中输入内容,直到我使用我的 Clear 函数。有趣的是,我可以退格但不能输入。
将此代码粘贴到 VB.NET 中并添加一个文本框和按钮。你会明白我的意思。
- 为什么文字会乱码?
- 为什么我无法在文本框中输入内容?
【问题讨论】:
标签: vb.net shell process vb.net-2010 command-prompt