no save
Assistance
Achat
News

Forum | programmation
VBscript et Base de donnée Access
lameche007, le lun. 20 juin 2005 à 12:34:27
EN faites voici Mon scrupt Qui me permet de recuperer l espace restant de mes disque ! et jeveux que a chaque lancement de se script ca ma stock les données concernant les disque dans une base de donnée type ACESS.Alors est ce que qu un peu me dire comment envoyer ses données a ma base Merci d avnce a toutes et a tous!!!



'----------------------------------------------------------
' Script de description des Hdd dans une page web
' ----------------------------------------------------------
Dim cnt
dim Aff()
dim Aff0()
dim Aff1()
dim Aff2()
dim Aff3()

cnt = 0
Redim Aff(cnt)
Redim Aff0(cnt)
Redim Aff1(cnt)
Redim Aff2(cnt)
Redim Aff3(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 ) ) )
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)
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=20%>"
ts.writeline "<p align=center><b>Name</b></td>"
ts.writeline "<td width=20%>"
ts.writeline "<p align=center><b>Drive</b></td>"
ts.writeline "<td width=20%>"
ts.writeline "<p align=center><b>Size</b></td>"
ts.writeline "<td width=20%>"
ts.writeline "<p align=center><b>Free</b></td>"
ts.writeline "<td width=20%>"
ts.writeline "<p align=center><b>% Free</b></td>"
ts.writeline "</tr>"
ts.writeline "<tr>"
for i = 0 to cnt
ts.writeline "<td width=20%><p align=center><b><font color=#FF0000>" & Aff(i) & "</font></b></td>"
ts.writeline "<td width=20%><p align=center><b><font color=#FF0000>" & Aff0(i) & "</font></b></td>"
ts.writeline "<td width=20%><p align=center><b><font color=#FF0000>" & Aff1(i) & "</font></b></td>"
ts.writeline "<td width=20%><p align=center><b><font color=#FF0000>" & Aff2(i) & "</font></b></td>"
ts.writeline "<td width=20%><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 14 juin 2005 par Mohax qui pète un plomb lol</font></b>"
ts.WriteLine "</CENTER></BODY>"
ts.WriteLine "</HTML>"
ts.close
End Sub
PrécédentLupin
juin 05
Lupin.Arsene
juin 05
Suivant
REPONSES
Lupin.Arsene
juin 05
lameche007
juin 05
Lupin.Arsene
juin 05
random
juin 05
Lupin
juin 05
lameche007
juin 05
Lupin.Arsene
juin 05
Lupin.Arsene
juin 05
lameche007
juin 05
lameche007
juin 05
Version Web
Réalisé par RedShift
no save