命令提示一个接一个 [英] Command Prompt one by one

查看:94
本文介绍了命令提示一个接一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在同一个cmd窗口中一个接一个地在VB 2010中输入DOS命令(不使用批处理文件)?每当我尝试输入新命令时,它会打开另一个cmd窗口。这是我目前所拥有的:

Is there a way to enter DOS commands in VB 2010 one after the other on the same cmd window (without using Batch files)? Whenever I try to enter a new command, it opens another cmd window. Here is what I currently have:

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim p As New Process
Dim psi As New ProcessStartInfo("cmd.exe", & txtCommand.text)

p.StartInfo = psi
p.Start()
p.WaitForExit()

End Sub

推荐答案

你必须打开命令提示符一次,然后您可以通过您创建的Process对象的StandardInput(Stream)属性向它发送命令。
You have to open the command prompt once, then you can send commands to it over the StandardInput (a Stream) property of the Process object you created.


这篇关于命令提示一个接一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆