I have found a vbscript on the internet that I would like to add some additional info to:
See below. I want to be able to get and save the computer name to each defrag log on a specified server in a specified folder...I've add computerName to the code below. Can someone tell me if I'm on the right track?
Also would like to be able to save time started and finished of each defrag run.
See below. I want to be able to get and save the computer name to each defrag log on a specified server in a specified folder...I've add computerName to the code below. Can someone tell me if I'm on the right track?
Also would like to be able to save time started and finished of each defrag run.
Code:
Const LogFile = "C:\Defrag.log"
Const DriveTypeRemovable = 1
Const DriveTypeFixed = 2
Const DriveTypeNetwork = 3
Const DriveTypeCDROM = 4
Const DriveTypeRAMDisk = 5
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Drives = FSO.Drives
For each Drive in Drives
if Drive.DriveType = 2 then
RunCmd Drive
end if
Next
Sub RunCmd(DriveString)
Set WshShell = WScript.CreateObject("WScript.Shell")
RunString = "%comspec% /c echo " & WeekDayName(WeekDay(Now), True) & " " & Now & " " & DriveString
Return = WshShell.Run(RunString & " >> " & ComputerName & LogFile & " 2>&1", 0, TRUE)
RunString = "%comspec% /c %WINDIR%\System32\Defrag.exe " & DriveString & " -f"
Return = WshShell.Run(RunString & " >> " & ComputerName & LogFile & " 2>&1", 0, TRUE)
Set WshShell = Nothing
End Sub
Comment