Solved

Use Chkdsk Exit Code to generate Alert

Posted on 2009-05-19
3
644 Views
Last Modified: 2012-05-07
Hello

I am looking to write a script - (vbscript or batch file or combo of both) to run chkdsk on all fixed disks on a given system (mostly servers) in read only mode.  If chkdsk encounters problems it would use the chkdsk exit codes or info in the chkdsk log to write alert us somehow that we should run a chkdsk /r

I believe I know how to do the actual alerting piece.  But how to pull the info from a chkdsk log or read the chkdsk exit codes is where I'm unsure
0
Comment
Question by:ITApprendista
3 Comments
 
LVL 3

Expert Comment

by:Cameron_S
ID: 24425609
You could write the script so the output of the chkdsk is put to a flat file (text file), then just have your script parse the flat file for the results and take action from there.
0
 
LVL 14

Expert Comment

by:BigBadWolf_000
ID: 24425747
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24426102
For a VBScript solution...
See: http://msdn.microsoft.com/en-us/library/ateytk4a(VS.85).aspx
and: http://msdn.microsoft.com/en-us/library/za76z6hh(VS.85).aspx

Example:

    Dim WshShell, oExec

    Set WshShell = CreateObject("WScript.Shell")
 

    Set oExec = WshShell.Exec("calc") ' <--- replacing "calc" with your app to run
 

    Do While oExec.Status = 0

         WScript.Sleep 100

    Loop
 

    WScript.Echo oExec.ExitCode

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now