本文介绍了如何使用VB.NET在cmd中编写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想在CMD编辑器中显示Hello world文本,但是当我使用这段代码时,我得到的结果就像这样 [ ^ ] 我希望文本只显示....... 私人 Sub Button2_Click( ByVal sender As System。 对象, ByVal e As System.EventArgs )句柄 Button2.Click Dim StartInfo As 新 System.Diagnostics.ProcessStartInfo StartInfo.FileName = cmd StartInfo.Re directStandardInput = True StartInfo.RedirectStandardOutput = True StartInfo.UseShellExecute = False Dim CMDprocess As 新处理 CMDprocess.StartInfo = StartInfo CMDprocess.Start() Dim sw As System.IO.StreamWriter = CMDprocess.StandardInput sw.WriteLine( Hello World) 结束 Sub 我的尝试: Dim sw As System.IO.StreamWriter = CMDprocess.StandardInput sw.WriteLine(Hello World) 解决方案 由于您正在向命令处理器发送Hello World,它正确地告诉您Hello不是命令。你需要在前面添加一个可识别的shell命令; 'echo'将是一个不错的选择。 I want to show "Hello world" text inside the CMD editor, but when I use this code I get the result like this "[^]"I want the text to appear only .......Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim StartInfo As New System.Diagnostics.ProcessStartInfo StartInfo.FileName = "cmd" StartInfo.RedirectStandardInput = True StartInfo.RedirectStandardOutput = True StartInfo.UseShellExecute = False Dim CMDprocess As New Process CMDprocess.StartInfo = StartInfo CMDprocess.Start() Dim sw As System.IO.StreamWriter = CMDprocess.StandardInput sw.WriteLine("Hello World")End SubWhat I have tried:Dim sw As System.IO.StreamWriter = CMDprocess.StandardInput sw.WriteLine("Hello World") 解决方案 Because you are sending "Hello World" to the command processor, and it correctly tells you that "Hello" is not a command. You need to add a recognisable shell command in front; 'echo' would be a good choice. 这篇关于如何使用VB.NET在cmd中编写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-22 02:03