G
gaxjyxq
Guest
Hello,
I want to get the cmd window content in realtime from a command line (Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore) in Windows 8 or 8.1
http://www.eightforums.com/tutorials/44348-winsxs-folder-component-store-analyze-windows-8-1-a.html
My code is below, but i can not get the progress percent values in realtime into the textbox, why?
Note: Need to untick the "Primarily 32bit" in the project compiling options in 64bit OS.
//////////////////////////////////////////////////////////////////////////////////////////
Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.CreateNoWindow = True
p.StartInfo.FileName = System.Environment.SystemDirectory & "\cmd.exe"
p.StartInfo.Arguments = "/c Dism /Online /Cleanup-Image /AnalyzeComponentStore"
AddHandler p.OutputDataReceived, AddressOf Process_OutputDataReceived
p.Start()
p.BeginOutputReadLine()
p.WaitForExit()
p.Close()
End Sub
Private Sub Process_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
If txtResult.InvokeRequired Then
txtResult.Invoke(New DataReceivedEventHandler(AddressOf Process_OutputDataReceived), sender, e)
Else
txtResult.Text += String.Format("{0}{1}", e.Data, Environment.NewLine)
End If
End Sub
Continue reading...
I want to get the cmd window content in realtime from a command line (Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore) in Windows 8 or 8.1
http://www.eightforums.com/tutorials/44348-winsxs-folder-component-store-analyze-windows-8-1-a.html
My code is below, but i can not get the progress percent values in realtime into the textbox, why?
Note: Need to untick the "Primarily 32bit" in the project compiling options in 64bit OS.
//////////////////////////////////////////////////////////////////////////////////////////
Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.CreateNoWindow = True
p.StartInfo.FileName = System.Environment.SystemDirectory & "\cmd.exe"
p.StartInfo.Arguments = "/c Dism /Online /Cleanup-Image /AnalyzeComponentStore"
AddHandler p.OutputDataReceived, AddressOf Process_OutputDataReceived
p.Start()
p.BeginOutputReadLine()
p.WaitForExit()
p.Close()
End Sub
Private Sub Process_OutputDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
If txtResult.InvokeRequired Then
txtResult.Invoke(New DataReceivedEventHandler(AddressOf Process_OutputDataReceived), sender, e)
Else
txtResult.Text += String.Format("{0}{1}", e.Data, Environment.NewLine)
End If
End Sub
Continue reading...