Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Public Class Form1
- Private psi As ProcessStartInfo
- Private cmd As Process
- Private Delegate Sub InvokeWithString(ByVal text As String)
- Public Sub runCMD()
- Try
- cmd.Kill()
- Catch ex As Exception
- End Try
- rtbResult.Clear()
- If txtCmd.Text.Contains("") Then
- psi = New ProcessStartInfo(txtCmd.Text.Split(" ")(0), txtCmd.Text.Split(" ")(1))
- Else
- psi = New ProcessStartInfo(txtCmd.Text$)
- End If
- ' Dim systemencoding As System.Text.Encoding
- System.Text.Encoding.GetEncoding(Globalization.CultureInfo.CurrentUICulture.TextInfo.OEMCodePage)
- With psi
- .UseShellExecute = False
- .RedirectStandardError = True
- .RedirectStandardOutput = True
- .RedirectStandardInput = True
- .CreateNoWindow = True
- ' .StandardOutputEncoding = systemencoding
- ' .StandardErrorEncoding = systemencoding
- End With
- cmd = New Process With {.StartInfo = psi, .EnableRaisingEvents = True}
- AddHandler cmd.ErrorDataReceived, AddressOf Async_Data_Received
- AddHandler cmd.OutputDataReceived, AddressOf Async_Data_Received
- cmd.Start()
- cmd.BeginOutputReadLine()
- cmd.BeginErrorReadLine()
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- runCMD()
- End Sub
- Private Sub Async_Data_Received(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
- Me.Invoke(New InvokeWithString(AddressOf Sync_Output), e.Data)
- End Sub
- Private Sub Sync_Output(ByVal text As String)
- rtbResult.AppendText(text & Environment.NewLine)
- rtbResult.ScrollToCaret()
- End Sub
- Private Sub CMDToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- ' Input.text = ""
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- MessageBox.Show("Cảm Ơn Các Bạn Đã Sữ Dụng Ứng Dụng Của Bờm Khùng" & vbCrLf & "Bờm Khùng Blogger Luôn Cung Cấp Những Ứng Dụng Free Cho Mọi Người" & vbCrLf & "Và Không Đính Kèm Virus Nhé Mọi Người ", "Thông Báo")
- Label1.Text = DateTime.Now.ToString
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- End Sub
- End Class
Add Comment
Please, Sign In to add comment