***

*** - VB/VBA/VBS - Programmation

Marsh Posté le 09-06-2011 à 15:57:52    

Bonjour,
quelqu'un pourrait modifier ce script pour récuperer l'inventaire de tous les disques connectés sur mon poste.  
ce script marche seulement pour les disques locaux
 
en vous remerciant
 
 
 
 
'----------------------------------------------------------  
' Script de description des Hdd dans une page web  
' ----------------------------------------------------------  
Dim cnt  
dim Aff()  
dim Aff0()  
dim Aff1()  
dim Aff2()  
dim Aff3()  
dim Aff4()  
 
cnt = 0  
Redim Aff(cnt)  
Redim Aff0(cnt)  
Redim Aff1(cnt)  
Redim Aff2(cnt)  
Redim Aff3(cnt)  
Redim Aff4(cnt)  
 
Select Case WScript.Arguments.Count  
Case 0  
' Default if none specified is local computer ("." )  
Set objWMIService = GetObject( "winmgmts://./root/cimv2" )  
Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )  
For Each objItem in colItems  
strComputer = objItem.Name  
Next  
Case 1  
' Command line parameter can either be a computer name  
' or "/?" to request online help  
strComputer = Wscript.Arguments(0)  
if InStr( strComputer, "?" ) > 0 Then Syntax  
Case Else  
' Maximum is 1 command line parameter  
Syntax  
End Select  
 
Display( strComputer )  
 
Function Display( strComputer )  
On Error Resume Next  
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )  
If Err.Number Then  
WScript.Echo vbCrLf & "Error # " & CStr( Err.Number ) & _  
" " & Err.Description  
Err.Clear  
Syntax  
End If  
On Error GoTo 0  
' Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk where MediaType=12",,48)  
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk where DriveType=3",,48)  
For Each objItem in colItems  
Aff(cnt) = strComputer  
Aff0(cnt) = objItem.Name & vbTab  
Aff1(cnt) = CStr( Int( 0.5 + ( objItem.Size / 1073741824 ) ) )  
Aff2(cnt) = CStr( Int( 0.5 + ( objItem.FreeSpace / 1073741824 ) ) )  
Aff4(cnt) = Aff1(cnt) - Aff2(cnt)
Aff3(cnt) = CStr( Int( 0.5 + ( 100 * objItem.FreeSpace / objItem.Size) ) ) & _  
vbCrLf  
cnt = cnt + 1  
Redim Preserve Aff(cnt)  
Redim Preserve Aff0(cnt)  
Redim Preserve Aff1(cnt)  
Redim Preserve Aff2(cnt)  
Redim Preserve Aff3(cnt)  
Redim Preserve Aff4(cnt)  
Next  
End Function  
 
' ----------------------------------------------------------  
Dim fso  
Set fso = WScript.CreateObject("Scripting.FileSystemObject" )  
DestHTML = "hd.HTML"  
CreateHTML DestHTML  
 
Sub CreateHTML(filename)  
dim ts  
set ts=fso.CreateTextFile(filename,true)  
ts.writeline "<HTML>"  
ts.WriteLine "<BODY>"  
ts.WriteLine "<b><CENTER><H3>Affiche les informations des HDD</H3></b>"  
ts.writeline "<table border=1 cellspacing=1 width=100%>"  
ts.writeline "<tr>"  
ts.writeline "<td width=15%>"  
ts.writeline "<p align=center><b>Name</b></td>"  
ts.writeline "<td width=15%>"  
ts.writeline "<p align=center><b>Drive</b></td>"  
ts.writeline "<td width=15%>"  
ts.writeline "<p align=center><b>Size</b></td>"  
ts.writeline "<td width=15%>"  
ts.writeline "<p align=center><b>Free</b></td>"  
ts.writeline "<td width=15%>"  
ts.writeline "<p align=center><b>Use</b></td>"  
ts.writeline "<td width=15%>"  
ts.writeline "<p align=center><b>% Free</b></td>"  
ts.writeline "</tr>"  
ts.writeline "<tr>"  
for i = 0 to cnt  
ts.writeline "<td width=15%><p align=center><b><font color=#FF0000>" & Aff(i) & "</font></b></td>"  
ts.writeline "<td width=15%><p align=center><b><font color=#FF0000>" & Aff0(i) & "</font></b></td>"  
ts.writeline "<td width=15%><p align=center><b><font color=#FF0000>" & Aff1(i) & "</font></b></td>"  
ts.writeline "<td width=15%><p align=center><b><font color=#FF0000>" & Aff2(i) & "</font></b></td>"  
ts.writeline "<td width=15%><p align=center><b><font color=#FF0000>" & Aff4(i) & "</font></b></td>"  
ts.writeline "<td width=15%><p align=center><b><font color=#FF0000>" & Aff3(i) & "</font></b></td>"  
ts.writeline "</tr>"  
next  
 
ts.writeline "</table>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<p> </p>"  
ts.writeline "<b><font size=2>Fait le " & now & " Pascal </font></b>"  
ts.WriteLine "</CENTER></BODY>"  
ts.WriteLine "</HTML>"  
ts.close  
End Sub

Reply

Marsh Posté le 09-06-2011 à 15:57:52   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed