1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

vbscript drive letter script :)

Discussion in 'Visual Basic ( VB )' started by luked, May 8, 2008.

  1. luked

    luked New Member

    Joined:
    May 8, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi all.
    could sumone plz help me out with a script that,
    a, ask for a drive letter
    b, displays the type of drive
    c, displayes its state (rdy or not rdy)
    d, displays its serial no.
    e, if no drive letter is entered or u hit esc or cancel the script should exit , saying no drive letter was entered.


    i have looked everywhere for a script like this but havent found any
    many thx in advance :)
     
  2. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    Here's you script :smile:

    Code:
    ' First creat an FSO object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    
    ' Drive specifications
    Dim Drv, DrvType, DrvName, DrvReady
    
    ' Get and format the drive name
    InputBox("Please enter drive letter :", DrvName)
    If Len(DrvName) > 1 Then DrvName = Left(DrvName,1)
    
    ' Check if user clicks "Cancel"
    If DrvName = "" Then End
    
    ' Continue :)
    Drv = FSO.GetDrive(DrvName)
    
    Select Case Drv.DriveType
                Case 0: DrvType = "Unknown"
                Case 1: DrvType = "Removable"
                Case 2: DrvType = "Fixed"
                Case 3: DrvType = "Network"
                Case 4: DrvType = "CD-ROM"
                Case 5: DrvType = "RAM Disk"
    End Select
    
    If Drv.IsReady Then DrvReady = "Ready" Else DrvReady = "Not Ready"
    
    MsgBox "Drive = " & DrvName & VbCrLf & "Drive Type = " & DrvType & VbCrLf &_
    "Drive State = " & DrvReady & VbCrLf & "Volume Name = " & Drv.VolumeName
    
     
    Last edited: May 7, 2009
    shabbir likes this.

Share This Page