• VBSCRIPT > les disques

       

       

       

      VÉRIFIER SI UN DISQUE EXISTE

       

      Function DriveExist(drv)
         Dim oFSO, msg
         Set oFSO = CreateObject("Scripting.FileSystemObject")
      
         If oFSO.DriveExists(drv) Then
            DriveExist = True
         Else
            DriveExist = False
         End If
      End Function 
      
      Msgbox DriveExist("D:\")
      MsgBox DriveExist("D")

       

       

      INFOS SUR LES DISQUES

       

      set fso = CreateObject("Scripting.FileSystemObject")
      set drive = fso.GetDrive("D")
      
      Wscript.Echo "AvailableSpace =", drive.AvailableSpace
      Wscript.Echo "DriveLetter    =", drive.DriveLetter
      Wscript.Echo "DriveType      =", drive.DriveType
      Wscript.Echo "FileSystem     =", drive.FileSystem
      Wscript.Echo "FreeSpace      =", drive.FreeSpace
      Wscript.Echo "IsReady        =", drive.IsReady
      Wscript.Echo "Path           =", drive.Path
      Wscript.Echo "RootFolder     =", drive.RootFolder
      Wscript.Echo "SerialNumber   =", drive.SerialNumber
      Wscript.Echo "ShareName      =", drive.ShareName
      Wscript.Echo "TotalSize      =", drive.TotalSize
      Wscript.Echo "VolumeName     =", drive.VolumeName

       

      you get this output

       

      AvailableSpace = 716756209664
      DriveLetter    = D
      DriveType      = 2
      FileSystem     = NTFS
      FreeSpace      = 716756209664
      IsReady        = -1
      Path           = D:
      RootFolder     = D:\
      SerialNumber   = 912945059
      ShareName      =
      TotalSize      = 1856350711808
      VolumeName     = TOTO

       

       

      dim objFSO, colDrives, objDrive, aff, tempaff
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set colDrives = objFSO.Drives
      For Each objDrive in colDrives
         if (objDrive.IsReady = true) then
            aff = "LETTRE DU DISQUE : " & objDrive.DriveLetter & vbcrlf
            aff = aff & "NOM DU DISQUE : " & objDrive.VolumeName & vbcrlf
            aff = aff & "NUMERO DE SERIE : " & objDrive.SerialNumber & vbcrlf
            aff = aff & "TYPE DE DISQUE : " & objDrive.DriveType & vbcrlf
            aff = aff & "SYSTEME DE FICHIERS : " & objDrive.FileSystem & vbcrlf
            aff = aff & "PATH : " & objDrive.Path & vbcrlf
            aff = aff & "DOSSIER RACINE : " & objDrive.RootFolder & vbcrlf
            aff = aff & "ESPACE TOTAL : " & objDrive.TotalSize & vbcrlf
            aff = aff & "ESPACE DISPONIBLE : " & objDrive.AvailableSpace & vbcrlf
            if (objDrive.ShareName <> "") then
               aff = aff & vbcrlf & "NOM DE PARTAGE : " & objDrive.ShareName
            end if
            MsgBox aff, vbInformation, "DiskInfo(brol)"
         else
            Wscript.Echo "DISQUE " & objDrive.DriveLetter & " NON PRET"
         end if
      Next
      Wscript.Echo colDrives.count & " DISQUES AFFICHES"

      Sub ShowDriveInfo(drvpath)
      Dim fs, d, s, t
      Set fs = CreateObject("Scripting.FileSystemObject")
      Set d = fs.GetDrive(drvpath)
      Select Case d.DriveType
      Case 0: t = "Unknown"
      Case 1: t = "Removable"
      Case 2: t = "Fixed"
      Case 3: t = "Network"
      Case 4: t = "CD-ROM"
      Case 5: t = "RAM Disk"
      End Select
      s = "Drive " & d.DriveLetter & ": - " & t
      If d.IsReady Then
      s = s & vbCrLf & "Drive is Ready."
      Else
      s = s & vbCrLf & "Drive is not Ready."
      End If
      Response.Write s
      End Sub

 

Aucun commentaire

 

Laissez un commentaire