Bonsoir,
Avec NetWork, c'est également possible.
'*********************** Mappage du server OXALYS ************
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
' WshNetwork.RemoveNetworkDrive "U:"
' WshNetwork.MapNetworkDrive "U:", "\\Oxalys\OXALYS\OXADATA\JOR"
If suffit de tester si le "Z" existe.
Ci-dessous, en exemple, un script listant les disques:
Call ShowFreePourcent()
MsgBox ShowFreePourcent
Function ShowFreePourcent()
Dim fso, d, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives 'permet de parcourir tous les disks
For Each d in dc
Select Case d.DriveType 'selection en fonction du type de lecteur
' Case 0: s = "Inconnu"
' Case 1: s = " Disk Amovible"
' Case 2: s = " Disk Fixe" & " => Espace disponible: " & d.AvailableSpace/1024 & " Koctets"
' Case 3: s = " Lecteur Réseau"
' Case 4: s = " Lecteur CD-ROM"
' Case 5: s = " Disk virtuel"
Case 2:
s = "Lecteur " & d.DriveLetter & ":" & vbCrLf
s = s & "Espace total en Go : " & FormatNumber(d.TotalSize/1024/1024/1024, 1) &vbCrLf
s = s & "Espace occupé en Go : " & FormatNumber(FormatNumber(d.TotalSize/1024/1024/1024, 1) - _
FormatNumber(d.AvailableSpace/1024/1024/1024, 1), 1) & vbCrLf
s = s & "Espace libre en Go : " & FormatNumber(d.AvailableSpace/1024/1024/1024, 1) & vbCrLf&vbCrLf
s = s & "Espace total en Mo : " & FormatNumber(d.TotalSize/1024/1024, 0) &vbCrLf
s = s & "Espace occupé en Mo : " & FormatNumber(FormatNumber(d.TotalSize/1024/1024, 0) - _
FormatNumber(d.AvailableSpace/1024/1024, 0), 0) & vbCrLf
s = s & "Espace libre en Mo : " & FormatNumber(d.AvailableSpace/1024/1024, 0) & vbCrLf&vbCrLf
s = s & "Espace total en Ko : " & FormatNumber(d.TotalSize/1024, 0) &vbCrLf
s = s & "Espace occupé en Ko : " & FormatNumber(FormatNumber(d.TotalSize/1024, 0) - _
FormatNumber(d.AvailableSpace/1024, 0), 0) & vbCrLf
s = s & "Espace libre en Ko : " & FormatNumber(d.AvailableSpace/1024, 0) & vbCrLf&vbCrLf
s = s & "Pourcentage occupé : " & FormatPercent((d.ToTalSize - d.AvailableSpace) / d.ToTalSize, 0) &vbCrLf
s = s & "Pourcentage libre : " & FormatPercent((d.AvailableSpace /_
d.TotalSize), 0) & vbCrLf&vbCrLf
result = result &vbCrLf& s &vbCrLf
Case Else
End Select
Next
ShowFreePourcent = result
End Function
===================================
jean-marc