Imports System.Diagnostics
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
System.Diagnostics.Process.Start("chkdsk.exe", "C:").WaitForExit()
End Sub
End Class
How to chkdsk with log using VB.net?
Page 1 of 13 Replies - 414 Views - Last Post: 25 May 2012 - 12:15 PM
#1
How to chkdsk with log using VB.net?
Posted 24 May 2012 - 05:59 AM
I only able to call the chkdsk command to dun but no idea how to log the chkdsk results. Please kindly help. Thanks.
Replies To: How to chkdsk with log using VB.net?
#2
Re: How to chkdsk with log using VB.net?
Posted 24 May 2012 - 07:14 AM
Alrighty well in this case I'll use the process class, because it's a really nifty tool!
You'll have to mess around with threading though because the UI will not update the richtextbox until it is done running the file and the arguments.
Using k As New Process 'Create a new class in a using block(good for disposing of objects!)
'filename, and arguments obviously
k.StartInfo.FileName = "chkdsk.exe"
k.StartInfo.Arguments = "C:"
'redirecting standard output so that the streamwriter will write to the richtextbox later on.
k.StartInfo.RedirectStandardOutput = True
k.StartInfo.UseShellExecute = False 'required to redirect the output
k.Start() 'starting the process based on the filename, and arguments
RichTextBox1.Text = k.StandardOutput.ReadToEnd() 'streamwriter writes all the results to the richtextbox.
End Using
You'll have to mess around with threading though because the UI will not update the richtextbox until it is done running the file and the arguments.
#3
Re: How to chkdsk with log using VB.net?
Posted 25 May 2012 - 03:09 AM
trevster344, on 24 May 2012 - 07:14 AM, said:
Alrighty well in this case I'll use the process class, because it's a really nifty tool!
You'll have to mess around with threading though because the UI will not update the richtextbox until it is done running the file and the arguments.
Using k As New Process 'Create a new class in a using block(good for disposing of objects!)
'filename, and arguments obviously
k.StartInfo.FileName = "chkdsk.exe"
k.StartInfo.Arguments = "C:"
'redirecting standard output so that the streamwriter will write to the richtextbox later on.
k.StartInfo.RedirectStandardOutput = True
k.StartInfo.UseShellExecute = False 'required to redirect the output
k.Start() 'starting the process based on the filename, and arguments
RichTextBox1.Text = k.StandardOutput.ReadToEnd() 'streamwriter writes all the results to the richtextbox.
End Using
You'll have to mess around with threading though because the UI will not update the richtextbox until it is done running the file and the arguments.
i have tried but seems like nothing happens... just a cmd.exe prompt very fast then nothing happen.
#4
Re: How to chkdsk with log using VB.net?
Posted 25 May 2012 - 12:15 PM
Try some different combinations to the arguments there are many ways to do it. You could even redirect the standard input, and write to it commands as well as using the sleep method to delay input times. Let me know if you need any more help.
This post has been edited by trevster344: 25 May 2012 - 02:36 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|