例如copy c:\aa.txt d:\cc.txt
谢谢
请写出头文件
8 个解决方案
#1
process.start("cmd.exe /c copy c:\aa.txt d:\cc.txt")
#2
Shell("cmd /k copy c:\aa.txt d:\cc.txt")
/c是运行后不保留cmd, /k是保留
用process.start会将启动的进程资源与process关联,这里不需要
/c是运行后不保留cmd, /k是保留
用process.start会将启动的进程资源与process关联,这里不需要
#3
来晚了,都说完了。
#4
process.start("cmd.exe /c copy c:\aa.txt d:\cc.txt")
#5
呵呵,上面这仁兄说完了。。
开个进程去执行其他的命令,
如果需要将dos程序执行结果显示到你的程序中。。需要用到管道技术。。
开个进程去执行其他的命令,
如果需要将dos程序执行结果显示到你的程序中。。需要用到管道技术。。
#6
NT系统下运行DOS命令(水如烟)
Private Sub CmdExcute()
Dim sw As System.IO.StreamWriter
Dim sr As System.IO.StreamReader
Dim err As System.IO.StreamReader
Dim p As System.Diagnostics.Process = New System.Diagnostics.Process
Dim psI As New System.Diagnostics.ProcessStartInfo(System.Environment.GetEnvironmentVariable("ComSpec"))
psI.UseShellExecute = False
psI.RedirectStandardInput = True
psI.RedirectStandardOutput = True
psI.RedirectStandardError = True
psI.CreateNoWindow = True
p.StartInfo = psI
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
p.Start()
sw = p.StandardInput
sr = p.StandardOutput
err = p.StandardError
sw.AutoFlush = True
If Me.tbComText.Text <> "" Then
sw.WriteLine(Me.tbComText.Text)
Else
sw.WriteLine("Dir ")
End If
sw.Close()
Me.tbResult.Text = sr.ReadToEnd()
Me.tbResult.Text += err.ReadToEnd()
Me.Cursor = System.Windows.Forms.Cursors.Default
End Sub
Private Sub CmdExcute()
Dim sw As System.IO.StreamWriter
Dim sr As System.IO.StreamReader
Dim err As System.IO.StreamReader
Dim p As System.Diagnostics.Process = New System.Diagnostics.Process
Dim psI As New System.Diagnostics.ProcessStartInfo(System.Environment.GetEnvironmentVariable("ComSpec"))
psI.UseShellExecute = False
psI.RedirectStandardInput = True
psI.RedirectStandardOutput = True
psI.RedirectStandardError = True
psI.CreateNoWindow = True
p.StartInfo = psI
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
p.Start()
sw = p.StandardInput
sr = p.StandardOutput
err = p.StandardError
sw.AutoFlush = True
If Me.tbComText.Text <> "" Then
sw.WriteLine(Me.tbComText.Text)
Else
sw.WriteLine("Dir ")
End If
sw.Close()
Me.tbResult.Text = sr.ReadToEnd()
Me.tbResult.Text += err.ReadToEnd()
Me.Cursor = System.Windows.Forms.Cursors.Default
End Sub
#7
up
#8
哈哈,真的是来晚咯!
#1
process.start("cmd.exe /c copy c:\aa.txt d:\cc.txt")
#2
Shell("cmd /k copy c:\aa.txt d:\cc.txt")
/c是运行后不保留cmd, /k是保留
用process.start会将启动的进程资源与process关联,这里不需要
/c是运行后不保留cmd, /k是保留
用process.start会将启动的进程资源与process关联,这里不需要
#3
来晚了,都说完了。
#4
process.start("cmd.exe /c copy c:\aa.txt d:\cc.txt")
#5
呵呵,上面这仁兄说完了。。
开个进程去执行其他的命令,
如果需要将dos程序执行结果显示到你的程序中。。需要用到管道技术。。
开个进程去执行其他的命令,
如果需要将dos程序执行结果显示到你的程序中。。需要用到管道技术。。
#6
NT系统下运行DOS命令(水如烟)
Private Sub CmdExcute()
Dim sw As System.IO.StreamWriter
Dim sr As System.IO.StreamReader
Dim err As System.IO.StreamReader
Dim p As System.Diagnostics.Process = New System.Diagnostics.Process
Dim psI As New System.Diagnostics.ProcessStartInfo(System.Environment.GetEnvironmentVariable("ComSpec"))
psI.UseShellExecute = False
psI.RedirectStandardInput = True
psI.RedirectStandardOutput = True
psI.RedirectStandardError = True
psI.CreateNoWindow = True
p.StartInfo = psI
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
p.Start()
sw = p.StandardInput
sr = p.StandardOutput
err = p.StandardError
sw.AutoFlush = True
If Me.tbComText.Text <> "" Then
sw.WriteLine(Me.tbComText.Text)
Else
sw.WriteLine("Dir ")
End If
sw.Close()
Me.tbResult.Text = sr.ReadToEnd()
Me.tbResult.Text += err.ReadToEnd()
Me.Cursor = System.Windows.Forms.Cursors.Default
End Sub
Private Sub CmdExcute()
Dim sw As System.IO.StreamWriter
Dim sr As System.IO.StreamReader
Dim err As System.IO.StreamReader
Dim p As System.Diagnostics.Process = New System.Diagnostics.Process
Dim psI As New System.Diagnostics.ProcessStartInfo(System.Environment.GetEnvironmentVariable("ComSpec"))
psI.UseShellExecute = False
psI.RedirectStandardInput = True
psI.RedirectStandardOutput = True
psI.RedirectStandardError = True
psI.CreateNoWindow = True
p.StartInfo = psI
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
p.Start()
sw = p.StandardInput
sr = p.StandardOutput
err = p.StandardError
sw.AutoFlush = True
If Me.tbComText.Text <> "" Then
sw.WriteLine(Me.tbComText.Text)
Else
sw.WriteLine("Dir ")
End If
sw.Close()
Me.tbResult.Text = sr.ReadToEnd()
Me.tbResult.Text += err.ReadToEnd()
Me.Cursor = System.Windows.Forms.Cursors.Default
End Sub
#7
up
#8
哈哈,真的是来晚咯!