gunsmokingman Posted May 21, 2006 Share Posted May 21, 2006 (edited) Here is a HTA that uses JS and VBS script that lists some general information for the Floppy, Hard Drive, Cd or DVD drive. This will also run the MS Clean Manager and you can choose what disk to Defrag or you can Defrag All the Hard drives. <HTML><HEAD><Title> Gsm Disk Info And Defrag</Title> <HTA:APPLICATION ID = "GsmDiskDefrag_V1" APPLICATIONNAME = "Gsm Disk Info And Defrag Version 1" BORDER = "thick" CAPTION = "Yes" SHOWINTASKBAR = "Yes" SINGLEINSTANCE = "Yes" SYSMENU = "no" WINDOWSTATE = "normal" SCROLL = "No" SCROLLFLAT = "Yes" VERSION = "1.3.1" INNERBORDER = "yes" SELECTION = "No" NAVIGABLE = "no" CONTEXTMENU = "yes" BORDERSTYLE = "normal" Icon="%SystemRoot%\Explorer.exe"> <STYLE type="text/css"> BODY { font:8pt Verdana; color:#000080; font-weight:bold; filter:progid:DXImageTransform.Microsoft.Gradient (GradientType=0,StartColorStr='#E2E2E2',EndColorStr='#6e6e6e); padding-top:1; padding-bottom:1; Text-Align:Center; } .Style1 { font:9pt Verdana; color:#000080; font-weight:bold; filter:progid:DXImageTransform.Microsoft.Gradient (GradientType=0,StartColorStr='#e1e1e1',EndColorStr='#9E9E9E'); padding-top:1; padding-bottom:1; Height:36; Text-Align:; } .Style2 { font:9pt Verdana; color:#187620;Text-Align:Left; font-weight:bold; } .Style3 { font:9pt Verdana; color:#187620;Text-Align:Center; font-weight:bold; } .Button { font:8.75pt; font-family:Palatino Linotype;color:white; filter:progid:DXImageTransform.Microsoft.Gradient (GradientType=0,StartColorStr='#E2E2E2',EndColorStr='#6e6e6e'); padding-top:1; padding-bottom:2; Text-Align:Center; Width:51;Height:23; } </STYLE> <!-- --> <script Language="JScript">// --> Resize The Window And Move window.resizeTo (610,275), window.moveTo (170,195); // --> Varibles And Objects var Fso = new ActiveXObject("Scripting.FileSystemObject"); var Act = new ActiveXObject("Wscript.Shell"); var GB = 1024 * 1024 * 1024 var MB = 1024 * 1024 var SD = Act.ExpandEnvironmentStrings("%SystemDrive%"); var Uname = Act.ExpandEnvironmentStrings("%UserName%"); var LB1 = "<Center>Select A Drive To List It Information And Defrag</Center>";//-> function B1text() { if (RBG.style.visibility == "hidden") {RBG.style.visibility = "",b1a.style.visibility = "", Label1.innerHTML="<BR>"} else {RBG.style.visibility = "hidden",b1a.style.visibility = "hidden", Label1.innerHTML=LB1;}}//-> function B2text() { if (RBG.style.visibility == "hidden") {RBG.style.visibility = "",b2a.style.visibility = "", Label1.innerHTML="<BR>"} else {RBG.style.visibility = "hidden",b2a.style.visibility = "hidden", Label1.innerHTML=LB1;}}//-> function B3text() { if (RBG.style.visibility == "hidden") {RBG.style.visibility = "",b3a.style.visibility = "", Label1.innerHTML="<BR>"} else {RBG.style.visibility = "hidden",b3a.style.visibility = "hidden", Label1.innerHTML=LB1;}}//-> function B4text() { if (RBG.style.visibility == "hidden") {RBG.style.visibility = "",b4a.style.visibility = "", Label1.innerHTML="<BR>"} else {RBG.style.visibility = "hidden",b4a.style.visibility = "hidden", Label1.innerHTML=LB1;}}//-> function B5text() { if (RBG.style.visibility == "hidden") {RBG.style.visibility = "",b5a.style.visibility = "", Label1.innerHTML="<BR>"} else {RBG.style.visibility = "hidden",b5a.style.visibility = "hidden", Label1.innerHTML=LB1;}}//-> function ClnMgr() { DF1.innerHTML = "Clean Manager Is Active" Act.run ("cleanmgr /sagerun:99",1 , true); DF1.innerHTML = "";}//-> function DoBoth() {ClnMgr(), Defrag();}//-> function HtaExit(){ var DelHta = Act.ExpandEnvironmentStrings("%SystemDrive%\DiskInfoDefrag_V2.Hta") if (Fso.FileExists(DelHta)) { Fso.DeleteFile(DelHta);} self.close();} </SCRIPT> <!-- --> <script Language='VBSCRIPT'> '/-> THESE ARE THE CONSTANCE FOR THE DRIVE TYPES Const Removable = 1, Fixed = 2, CD_DVD = 4'/-> THESE ARE THE CONSTANCE FOR THE TEXT FILE Const ForReading = 1 </SCRIPT> <script Language='VBSCRIPT'> '--> Varibles For Drives Dim Dtype, FreeSpace, PerCentSize, strD, TotalSpace, UsedSpace, VName'--> Varibles For The Text File And Onload Event Dim Intc, objFile, objOption, strDrive, trNewFile'--> Builds The Text File That List The Drive Letter For The List Box Dim Drv : Set Drv = Fso.Drives Dim Ts : Set Ts = Fso.OpenTextFile("DriveList.Txt",2,true) Ts.WriteLine "Select A Drive" For Each strDrive in Drv Ts.WriteLine strDrive Next Ts.close'--> Array For The Rest VBS Scripts Dim Rs : Rs = Array(SD & "\RestF.vbs",SD & "\Rest1.vbs",SD & "\Rest2.vbs",SD & "\Rest3.vbs")'--> Builds The Drop List Box Function Window_Onload strNewFile = "DriveList.Txt" Set objFile = Fso.OpenTextFile(strNewFile, ForReading) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine Set objOption = Document.createElement("OPTION") objOption.Text = strLine objOption.Value = strLine AvailableComputers.Add(objOption) Loop objFile.Close Intc = 1-1 Do Intc = Intc + 1 Loop Until Intc = 1000 Fso.DeleteFile("DriveList.Txt") End Function'--> Sleep Function .5 Second Stop Function RstF() Dim Ts : Set Ts = Fso.OpenTextFile(Rs(0), 2, true) Ts.WriteLine "Wscript.sleep 50" : Ts.close Act.run(Rs(0)), 1 , True : Fso.DeleteFile(Rs(0)) End Function '--> Sleep Function 1.0 Second Stop Function Rst1() Dim Ts : Set Ts = Fso.OpenTextFile(Rs(1), 2, true) Ts.WriteLine "Wscript.sleep 1000" : Ts.close Act.run(Rs(1)), 1 , True : Fso.DeleteFile(Rs(1)) End Function'--> Sleep Function 2.2 Second Stop Function Rst2() Dim Ts : Set Ts = Fso.OpenTextFile(Rs(2), 2, true) Ts.WriteLine "Wscript.sleep 2200" : Ts.close Act.run(Rs(2)), 1 , True : Fso.DeleteFile(Rs(2)) End Function '--> Sleep Function 3.3 Second Stop Function Rst3() Dim Ts : Set Ts = Fso.OpenTextFile(Rs(3), 2, true) Ts.WriteLine "Wscript.sleep 3300" : Ts.close Act.run(Rs(3)), 1 , True : Fso.DeleteFile(Rs(3)) End Function '--> Drop List Drive Info Function DrvInfo() For Each strD in Fso.Drives If strD = AvailableComputers.Value Then If StrD.IsReady = True Then'--> Varibles FreeSpace = StrD.FreeSpace : TotalSpace = StrD.TotalSize PerCentSize = FreeSpace / TotalSpace : UsedSpace = TotalSpace - FreeSpace VName = strD.VolumeName'--> Display The Text GetDrvType() DF1.innerHTML = "This Drive Is Active" DF2.innerHTML = DType ConvertSize() : Rst3()'--> Ask User If They Want To Defrag The Selected Hard Drive DfragIt = Window.confirm ("Would You Like To Defrag This Drive" &_ Vbcrlf & "Disk " & chr(187) & chr(160) & strD &"\" & strD.VolumeName) If DFragIt = True Then If StrD.DriveType = 2 Then RunDefrag() : ClearText() End If End If End If'--> If User Cancel The Defrag If DFragIt = False Then ClearText() End If'--> If The Drive Is Not Active If StrD.IsReady = False Then GetDrvType() Disk.innerHTML = strD & "\" DF1.innerHTML = "This Drive Is Not Active, " & DType DF2.innerHTML = Uname & ", Please Select Another Drive" Rst3() : Rst3() : ClearText() End If End If Next End Function'--> Clears All The Text Display Function ClearText()'--> Clears The Text In The Bar Display Area Disk.innerHTML = "" : VolName.innerHTML = "" Size.innerHTML = "" : Free.innerHTML = "" PctFree.innerHTML = "" : Used.innerHTML = "" FSys.innerHTML = ""'--> Clears The Lower Text Display Area DF1.innerHTML = "" : DF2.innerHTML = "" End Function '--> Display All The Drives Info Function AllDrvInfo() For Each strD in Fso.Drives If StrD.IsReady = True Then'--> Varibles FreeSpace = StrD.FreeSpace : TotalSpace = StrD.TotalSize PerCentSize = FreeSpace / TotalSpace : UsedSpace = TotalSpace - FreeSpace VName = strD.VolumeName'--> Display The Text Then Clears The Text GetDrvType() DF1.innerHTML = "This Drive Is Active" DF2.innerHTML = DType ConvertSize() : Rst3() : Rst3() : ClearText() End If If StrD.IsReady = False Then GetDrvType() Disk.innerHTML = strD & "\" DF1.innerHTML = "This Drive Is Not Active" DF2.innerHTML = DType Rst3 : Rst3 : ClearText() End If Next End Function '--> Defrag Display Text Function Defrag() For Each strD in Fso.Drives If StrD.DriveType = 2 Then'--> Varibles FreeSpace = StrD.FreeSpace : TotalSpace = StrD.TotalSize PerCentSize = FreeSpace / TotalSpace : UsedSpace = TotalSpace - FreeSpace VName = strD.VolumeName'--> Display The Text Then Runs Defrag Then Clears The Text ConvertSize() : Rst3() : RunDefrag() : ClearText() End If Next End Function '--> Defrag All Hard Drives Function RunDefrag() DF1.innerHTML = "Preparing To Defrag This Drive, " & strD & "\" DF2.innerHTML = "This Will Take A Few Minutes" Rst3() Act.Run("Defrag " & strD & "\ -F"),2,True Df1.innerHTML = "Completed Disk Defrag" DF2.innerHTML = "Prearing For Next Drive" Rst3() Exit Function End Function'--> Converts The Size To GB OR MB And Text Display Function ConvertSize() If StrD.TotalSize > GB Then Disk.innerHTML = strD & "\" VolName.innerHTML = VName Size.innerHTML = Left(round(100*TotalSpace/(GB)/100,4),5) & " GB" Free.innerHTML = Left(round(100*FreeSpace/(GB)/100,4),5) & " GB" PctFree.innerHTML = FormatPercent(PerCentSize) Used.innerHTML = Left(UsedSpace/(GB),5) & " GB" FSys.innerHTML = strD.FileSystem Else Disk.innerHTML = strD & "\" VolName.innerHTML = VName Size.innerHTML = Left(round(100*TotalSpace/(MB)/100,4),5) & " MB" Free.innerHTML = Left(round(100*FreeSpace/(MB)/100,4),5) & " MB" PctFree.innerHTML = FormatPercent(PerCentSize) Used.innerHTML = Left(UsedSpace/(MB),5) & " MB" FSys.innerHTML = strD.FileSystem End If Exit Function End Function'--> Get The Drive Type Function GetDrvType()'--> Floppy Disk Drive If StrD.DriveType = Removable Then Dtype = "Floppy Disk" End If'--> Hard Drive If StrD.DriveType = Fixed Then Dtype = "Hard Drive" End If'--> CD OR DVD Drive If StrD.DriveType = CD_DVD Then Dtype = "CD or DVD Drive" End If Exit Function End Function </SCRIPT> </HEAD><Body Class='Normal'> <!-- LABEL --> <Table Width=98%><TD Style='font:9pt Verdana;color:#000080;Text-Align:Left;font-weight:bold;'> <Span ID='Label1'><Center>Select A Drive To List It Information And Defrag</Center></Span></TD></Table> <!-- DISPALY BAR 'List The Drive Info. If It A Hard Drive Then It Ask If You Want To Defrag It' --> <Table Width=98% Align='Center'><TD Class='Style1'><Table Align='Center'> <TD onmouseover="B1text()" onmouseout="B1text()"> <select STYLE='font:8.25pt Palatino Linotype;color:#000080;font-weight:Bold;' size='1' language='' onChange='DrvInfo()' Name='AvailableComputers'></TD><TD> <Input Type='Button' Value='ListAll' Class='Button' Style='cursor:Hand;' OnClick='AllDrvInfo()' onmouseover="B2text()" onmouseout="B2text()"> <Input Type='Button' Value='Defrag' Class='Button' Style='cursor:Hand;' OnClick='Defrag()' onmouseover="B3text()" onmouseout="B3text()"> <Input Type='Button' Value='Clean' Class='Button' Style='cursor:Hand;' OnClick='ClnMgr()' onmouseover="B4text()" onmouseout="B4text()"> <Input Type='Button' Value='DoBoth' Class='Button' Style='cursor:Hand;' OnClick='DoBoth()' onmouseover="B5text()" onmouseout="B5text()"> <Input Type='Button' Value='Close' Class='Button' Style='cursor:Hand;' OnClick='HtaExit()'> </TD></Table></TD></Table> <!-- DISK LETTER --> <Table Border='1' Width=98%> <TD Name='Disk' Class='Style1' Width=3%> Disk <Table><TD Name='DiskT' Height=16> <Span Id='Disk' Style='font:8pt Verdana;color:#5f6363;Text-Align:Left;font-weight:bold;'></Span> </TD></Table></TD> <!-- VOLUME NAME --> <TD Name='VolName' Class='Style1' Width=8%> Volume Name <Table><TD Name='VolNameT' Height=16> <Span Id='VolName' Style='font:8pt Verdana;color:#5f6363;Text-Align:Left;font-weight:bold;'></Span> </TD></Table></TD> <!-- TOTAL SIZE --> <TD Name='Size' Class='Style1' Width=5%> Size <Table><TD Name='SizeT' Height=16> <Span Id='Size' Style='font:8pt Verdana;color:#187620;Text-Align:Left;font-weight:bold;'></Span> </TD></Table></TD> <!-- FREE SPACE --> <TD Name='Free' Class='Style1' Width=5%> Free <Table><TD Name='FreeT' Height=16> <Span Id='Free' Style='font:8pt Verdana;color:#54709e;Text-Align:Left;font-weight:bold;'></Span> </TD></Table></TD> <!-- PERCENT FREE SPACE --> <TD Name='Percent' Class='Style1' Width=5%> %Free <Table><TD Name='PctFreeT' Height=16> <Span Id='PctFree' Style='font:8pt Verdana;color:#54709e;Text-Align:Left;font-weight:bold;'></Span> </TD></Table></TD> <!-- USED SPACE --> <TD Name='Used' Class='Style1' Width=5%> Used <Table><TD Name='UsedT' Height=16> <Span Id='Used' Style='font:8pt Verdana;color:#9e3040;Text-Align:Left;font-weight:bold;'></Span> </TD></Table></TD> <!-- USED SPACE PERCENT --> <TD Name='PctUsed' Class='Style1' Width=7%> File System <Table><TD Name='FsysT' Height=16> <Span Id='FSys' Style='font:8pt Verdana;color:#5f6363;Text-Align:Left;font-weight:bold;'></Span> </TD></Table></TD></Table> <!-- TEXT MESSAGE FOR ERRORS AND DEFRAG 001 --> <Table><TD Name='DF1T' Height=16><Span Id='DF1' Class='Style2'></Span></TD></Table> <!-- TEXT MESSAGE FOR ERRORS AND DEFRAG 002 --> <Table><TD Name='DF2T' Height=16><Span Id='DF2' Class='Style2'></Span></TD></Table> </HTML></BODY> <!-- ===================================================================================== --> <Div id="RBG" style="visibility:hidden; position:absolute; top:1; Left:1; width:1; height:1; background-color: white; filter:progid:DXImageTransform.alpha(opacity=100); filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#bbb7b3', EndColorStr='#c4c0bb')"> </DIV> <!-- ===================================================================================== --> <Div id="b1a" style="visibility:hidden;color:;position:absolute;top:5;left:15;width:550;height:18; margin-top:5; margin-left:5;"> <P Class="Style3">List The Drive Info. If It A Hard Drive Then It Ask If You Want To Defrag It</DIV> <!-- ===================================================================================== --> <Div id="b2a" style="visibility:hidden;color:;position:absolute;top:5;left:15;width:550;height:18; margin-top:5; margin-left:5;"> <P Class="Style3">List All The Floppy, Hard Drive, CD Or DVD Drive Info On The Local Computer</DIV> <!-- ===================================================================================== --> <Div id="b3a" style="visibility:hidden;color:;position:absolute;top:5;left:15;width:550;height:18; margin-top:5; margin-left:5;"> <P Class="Style3">Defrag The Local Computer Hard Drives</DIV> <!-- ===================================================================================== --> <Div id="b4a" style="visibility:hidden;color:;position:absolute;top:5;left:15;width:550;height:18; margin-top:5; margin-left:5;"> <P Class="Style3">Run The Microsoft Clean Manager On The Local Computer Hard Drives</DIV> <!-- ===================================================================================== --> <Div id="b5a" style="visibility:hidden;color:;position:absolute;top:5;left:15;width:550;height:18; margin-top:5; margin-left:5;"> <P Class="Style3">Run The Microsoft Clean Manager And Defrag On The Computer Local Hard Drives</DIV>Here is the HTA in a SFXDiskInfoDefrag_V2.exe Edited April 20, 2009 by gunsmokingman Link to comment Share on other sites More sharing options...
GeneralMandible Posted June 15, 2006 Share Posted June 15, 2006 What versions of Windows does this run on?Does it use MS' defrag utility? Link to comment Share on other sites More sharing options...
gunsmokingman Posted June 15, 2006 Author Share Posted June 15, 2006 (edited) I have been using this on XP, and it uses the built in CleanMgr and DefragIf you would like help with your project, I would be glad to help you on it. Edited June 15, 2006 by gunsmokingman Link to comment Share on other sites More sharing options...
GeneralMandible Posted June 15, 2006 Share Posted June 15, 2006 I may look into using just vbscript or maybe even a VB app. Thanks for the offer & I might take you up on it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now