REM =============================================================== REM Fichier : C:\o\vbs\free_space.vbs REM Description : affiche l'espace libre sur les disques fixes locaux REM =============================================================== disques="abcdefghijklmnopqrstuvwxyz" Const nbDecimales = 1 Function Formater(a) Form1 = formatnumber(a,nbDecimales) lForm1=len(Form1) Formater = left(" ",6-lForm1) & Form1 end Function Function Formater2(a) Formater2 = left(" ",8-len(a)) & a end Function Function Espace_libre(disque,totalsize) Set filesys = CreateObject("Scripting.FileSystemObject") Set drv = filesys.GetDrive(disque) Espace_libre = drv.AvailableSpace/1024/1024/1024 totalsize = drv.totalsize/1024/1024/1024 end function Function Test_Partition(disque) on error resume next Test_Partition = False Set filesys = CreateObject("Scripting.FileSystemObject") Set drv = filesys.GetDrive(disque) if err then exit function if drv.DriveType=2 then Test_Partition=True end function Function Pourcent(a,b) Pourcent = FormatNumber (a/b*100,0) & " %" End Function Sub Main1 totalsize = 0 freesize = 0 total_totalsize = 0 total_free = 0 a="_____________________________________________" & vbcrlf & _ "Lettre Espace libre Espace TOTAL" & vbcrlf & _ "_____________________________________________" for i=1 to len(disques) lettre = mid(disques,i,1) if Test_Partition(lettre)=true then freesize = Espace_libre(lettre,totalsize) total_free = total_free + freesize total_totalsize = total_totalsize + totalsize a = a & vbcrlf & " " & lettre & chr(9) & chr(9) & _ Formater(freesize) & chr(9) & chr(9) & _ Formater(totalsize) end if next a = a & vbcrlf & "_____________________________________________" a = a & vbcrlf & " TOTAUX " & chr(9) & Formater(total_free) & " Go " & chr(9) & chr(9) & Formater(total_totalsize) & " Go" if msgbox(a,1,"Espace libre/total des partitions")=1 then main2 End Sub '=========== Sub Main2 '=========== totalsize = 0 freesize = 0 '============================= disques="abcdefghijklmnopqrstuvwxyz" a="Lettre Espace libre Espace TOTAL" & vbcrlf & _ "---------------------------------------------------------------------------" for i=1 to len(disques) lettre = mid(disques,i,1) if Test_Partition(lettre)=true then freesize = Espace_libre(lettre,totalsize) a = a & vbcrlf & " " & lettre & chr(9) & chr(9) & Formater2(Pourcent(freesize,totalsize)) & chr(9) & chr(9) & Formater2(Pourcent(totalsize,total_totalsize)) end if next a = a & vbcrlf & "---------------------------------------------------------------------------" a = a & vbcrlf & " TOTAUX " & Pourcent(total_free,total_totalsize) & chr(9) & chr(9) & " 100 %" if msgbox(a,1,"POURCENTAGES")=1 then main1 End Sub dim total_totalsize dim total_free main1