Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to schedule chkdsk to run at shutdown?! and HDD Health status

Posted on 2008-10-29
6
Medium Priority
?
864 Views
Last Modified: 2013-12-01
Hi,
1. I like to schedule chkdsk at shutdown for all the 25 systems in our concern, at a regular interval.

2. How to run Hard Disk Diagnostic utility automatically at  regular interval(say once in a month).

Kindly suggest me any built-in options for the above two (or) any Third party Application to achive the result.

Thanks in Advance,
regards
Kriish
0
Comment
Question by:kriishvp
  • 4
6 Comments
 
LVL 1

Expert Comment

by:d4t2ill4
ID: 22838366
You can specify in computer policy to execute script/command on shutdown/log off.

guide: http://techsupt.winbatch.com/ts/T000001048F90.html.

you can use the AT.exe command to schedule tasks on remote computer. http://support.microsoft.com/kb/313565
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 22838855
What I think is that chkdsk will only run at startup even before windows gains control over hard disk operations. So I do not think it will be possible at shutdown.

Saqib
0
 
LVL 1

Expert Comment

by:d4t2ill4
ID: 22845240
ssaqibh is correct, you can not chkdsk for system drives or drive that contains pagefile. chkdsk will schedule chkdsk on the next boot and the result on be seen in eventviewer. I've got a simple script schedule chkdsk at next boot which I schedule to run at shutdown. I hope this helps.

Option Explicit

Dim objFSO, objShell, objEnv, objReg
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objEnv = objShell.Environment("PROCESS")
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

Dim intExitCode
intExitCode = 0

objEnv("SEE_MASK_NOZONECHECKS") = 1

Dim strScriptPath, objDrive, arrChkdskRegString
strScriptPath = objFSO.GetParentFolderName (WScript.ScriptFullName)
arrChkdskRegString = Array ()

For Each objDrive In objFSO.Drives
      If objDrive.DriveType = 2 Then
            arrChkdskRegString = AddArrayRecord (arrChkdskRegString, "autocheck autochk /r \??\" & objDrive.DriveLetter & ":")
      End If
Next

arrChkdskRegString = AddArrayRecord (arrChkdskRegString, "autocheck autochk *")

Const HKLM = &H80000002
Dim strKeyPath, strValueName
strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager"
strValueName = "BootExecute"

objReg.CreateKey HKLM,strKeyPath
objReg.SetMultiStringValue HKLM, strKeyPath, strValueName, arrChkdskRegString

objEnv("SEE_MASK_NOZONECHECKS") = 0
WScript.Quit intExitCode

Function AddArrayRecord (arrTempArray(), strValue)
      ReDim Preserve  arrTempArray (UBound(arrTempArray) + 1)
      arrTempArray (UBound(arrTempArray)) = strValue
      AddArrayRecord = arrTempArray
End Function
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kriishvp
ID: 22855870
Hi d4t2ill4,

Is it possible to assign the script as shutdown script and also not allowing the user to skip the chkdsk.

~kriish
0
 
LVL 1

Expert Comment

by:d4t2ill4
ID: 22856067
Shutdown scripts run as Local System account (not logoff). you can run this script at shutdown. The script i showed you will schedule chkdsk at next bootup. Once you have passed the allowed cancel time at bootup, user can not cancel except force distruption such as shutdown. But I suggest you don't run chkdsk during business hour because a thorough scan can take up to a few hours to complete depending on the drive size.

This script only takes 1 second to run but there's a way you can hide all shutdown script so the user can not see.
http://www.pctools.com/guides/registry/detail/1087/.
I hope this helps.
Cheers
0
 
LVL 1

Accepted Solution

by:
d4t2ill4 earned 150 total points
ID: 22856076
Sorry, if you want to know where  the shutdown script policy is located in the Registry, this website can help.
http://www.msfn.org/board/lofiversion/index.php/t40945.html

more example on logon/shutdown/logoff scripts
http://techsupt.winbatch.com/ts/T000001048F90.html

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

886 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