Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6356275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:55:56+00:00 2026-05-24T22:55:56+00:00

I have a Vb-script which store all removable drives’ letters into a variable, As

  • 0

I have a Vb-script which store all removable drives’ letters into a variable, As you know it contains both floppy and USB drives, I want to seperate them, I mean I want to store USB Drives’ Letters in a variable and Floppy ones into another variable,

Here is the script:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")

Removable = ""
For Each objDisk in colDisks
  if objDisk.DriveType = 2 then
    if Removable > "" then
      Removable = Removable & ";"
    end if
    Removable = Removable & objDisk.DeviceID & "\"
  end if
Next

I’m using a software which can call VBScript. But it only support some kind of them like which I posted. So How can I do what I told?

Thanks in Advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:55:57+00:00Added an answer on May 24, 2026 at 10:55 pm

    Check objDisk.MediaType. Here you’ll find a list of MediaTypes; at a first glance MediaType 1 … 10 indicates a ‘normal’ floppy; in a quick check on my (virtual) machine, an USB drive showed a MediaType of Null (not even Zero for Unknown), so you’ll have do be careful. At a second glance (talking about carefull): most defined media types identify floppies (some of them exotic). BTW – what about USB floppy drives?


    As I can’t test on a ‘real’ computer, you’ll have to double check the following code:

    Const cnRemovableDisk =  2
    Const cnMTypeUnknown  =  0
    Const cnMTypeNoFloppy = 11
    Const cnMTypeFixedHD  = 12
    Dim strComputer   : strComputer       = "."
    Dim objWMIService : Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Dim colDisks      :  Set colDisks = objWMIService.ExecQuery _
        ("Select * from Win32_LogicalDisk")
    Dim Removable     : Removable = ""
    Dim Floppy        : Floppy    = ""
    Dim USBDrive      : USBDrive  = ""
    Dim objDisk
    For Each objDisk in colDisks
      If objDisk.DriveType = cnRemovableDisk Then
         Removable = Removable & ";" & objDisk.DeviceID & "\"
         Select Case True
           Case IsNull( objDisk.MediaType )
              WScript.Echo objDisk.DeviceID, "has MediaType null - assuming USB Drive."
              USBDrive = USBDrive & ";" & objDisk.DeviceID & "\"
           Case objDisk.MediaType = cnMTypeNoFloppy
              WScript.Echo objDisk.DeviceID, "has MediaType 11 - assuming USB Drive."
              USBDrive = USBDrive & ";" & objDisk.DeviceID & "\"
           Case objDisk.MediaType = cnMTypeUnknown
              WScript.Echo objDisk.DeviceID, "has MediaType 0 - assuming USB Drive."
              USBDrive = USBDrive & ";" & objDisk.DeviceID & "\"
           Case objDisk.MediaType = cnMTypeFixedHD
              WScript.Echo objDisk.DeviceID, "has MediaType 12 - how can this happen?"
           Case Else
              WScript.Echo objDisk.DeviceID, "has MediaType", objDisk.MediaType, " - surely some kind of floppy."
              Floppy   = Floppy   & ";" & objDisk.DeviceID & "\"
         End Select
      End If
    Next
    Removable = Mid( Removable, 2 )
    Floppy    = Mid( Floppy   , 2 )
    USBDrive  = Mid( USBDrive , 2 )
    WScript.Echo "Removable:", Removable
    WScript.Echo "Floppy:   ", Floppy
    WScript.Echo "USBDrive: ", USBDrive
    

    my output is:

    A: has MediaType 5  - surely some kind of floppy.
    F: has MediaType null - assuming USB Drive.
    Removable: A:\;F:\
    Floppy:    A:\
    USBDrive:  F:\
    

    The null MediaType of my USBDrive may be a freakish accident. I tried to make tinkering with the evaluating of the MediaType easy by using a “Select Case True” control structure. VBScript will test the conditions of the Cases until the first true one, execute the corresponding statement(s), and ‘break’ to the End Select. So adding special cases and/or reordering cases is straightforward – just keep the IsNull check at first position.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which contains two classes. (I'm obviously deleting a lot of
I have a script which contacts a few sources and tell them the IP-address
I have a script which logs on to a remote server and tries to
I have a script which will be run interactively by non-technical users. The script
I have this script which basically toggles a bgColor class on and off so
I have a script which hides (display:none) certain divs in the list on page
I have a script which creates a user-defined object like this: obj = new
I have a script which, each time is called, gets the first line of
I have a script which tracks visits & referers to a website. I send
I have a script which returns a price for a product. However, the price

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.