kriishvp
asked on
How to schedule chkdsk to run at shutdown?! and HDD Health status
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
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
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
Saqib
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.Shel l")
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objEnv = objShell.Environment("PROC ESS")
Set objReg = GetObject("winmgmts:{imper sonationLe vel=impers onate}!\\. \root\defa ult:StdReg Prov")
Dim intExitCode
intExitCode = 0
objEnv("SEE_MASK_NOZONECHE CKS") = 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\Se ssion Manager"
strValueName = "BootExecute"
objReg.CreateKey HKLM,strKeyPath
objReg.SetMultiStringValue HKLM, strKeyPath, strValueName, arrChkdskRegString
objEnv("SEE_MASK_NOZONECHE CKS") = 0
WScript.Quit intExitCode
Function AddArrayRecord (arrTempArray(), strValue)
ReDim Preserve arrTempArray (UBound(arrTempArray) + 1)
arrTempArray (UBound(arrTempArray)) = strValue
AddArrayRecord = arrTempArray
End Function
Option Explicit
Dim objFSO, objShell, objEnv, objReg
Set objShell = CreateObject("WScript.Shel
Set objFSO = CreateObject("Scripting.Fi
Set objEnv = objShell.Environment("PROC
Set objReg = GetObject("winmgmts:{imper
Dim intExitCode
intExitCode = 0
objEnv("SEE_MASK_NOZONECHE
Dim strScriptPath, objDrive, arrChkdskRegString
strScriptPath = objFSO.GetParentFolderName
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\
strValueName = "BootExecute"
objReg.CreateKey HKLM,strKeyPath
objReg.SetMultiStringValue
objEnv("SEE_MASK_NOZONECHE
WScript.Quit intExitCode
Function AddArrayRecord (arrTempArray(), strValue)
ReDim Preserve arrTempArray (UBound(arrTempArray) + 1)
arrTempArray (UBound(arrTempArray)) = strValue
AddArrayRecord = arrTempArray
End Function
ASKER
Hi d4t2ill4,
Is it possible to assign the script as shutdown script and also not allowing the user to skip the chkdsk.
~kriish
Is it possible to assign the script as shutdown script and also not allowing the user to skip the chkdsk.
~kriish
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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