3 Replies - 414 Views - Last Post: 25 May 2012 - 12:15 PM Rate Topic: -----

#1 stella222  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 24-May 12

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.
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


Is This A Good Question/Topic? 0
  • +

Replies To: How to chkdsk with log using VB.net?

#2 trevster344  Icon User is online

  • The Peasant
  • member icon

Reputation: 209
  • View blog
  • Posts: 1,365
  • Joined: 16-March 11

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!

        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.
Was This Post Helpful? 1
  • +
  • -

#3 stella222  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 24-May 12

Re: How to chkdsk with log using VB.net?

Posted 25 May 2012 - 03:09 AM

View Posttrevster344, 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!

        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.
Was This Post Helpful? 0
  • +
  • -

#4 trevster344  Icon User is online

  • The Peasant
  • member icon

Reputation: 209
  • View blog
  • Posts: 1,365
  • Joined: 16-March 11

Re: How to chkdsk with log using VB.net?

Posted 25 May 2012 - 12:15 PM

Hmm I'll see what's up when I get home. Sorry about that, it had worked on my compiler.

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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1