Ask a Question

Need to find Label or Serial for removable drive(s)

Occasional Contributor

Need to find Label or Serial for removable drive(s)

TC version: 7.52

Script language: Delphi

I am currently making some tests for accessing a removable drive to read a file on it.

Problem is, that I can't be certain that the drive always gets the same drive letter.

So I need to find a unique identifier for it. This could either be the Label for the drive, or the serial. I had a look into the aqFileSystems.Drives property, I can see that it is possible to find a drive's serial. I used the following call:

drv := aqFileSystem.Drives(0).SerialNumber;

But all I get in return is 'Unknown'. If I Inspect the object aqFileSystem.Drives(0), I can see that serial contains a value.

If I use aqFileSystem.Drives(0).DriveLetter, then I get the value shown for that property.

How do I extract the Serial value?? ... or is it at all possible to find the drive's label instead??

Any help would be appreciated.
Champion Level 2

Hi Anders,


works fine for me.

Maybe the reason of your problem is that Drives(0) corresponds to the A: drive which is empty?
  /Alex [Community Champion]
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.

Hi Anders,

This issue is solved in TC 8.

For TC 7, you need to convert the returned value to float (VarToFloat) or to string (VarToStr). For example:

drv := aqConvert.VarToFloat(aqFileSystem.Drives(0).SerialNumber)

See the aqDriveInfo.SerialNumber help topic.
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Occasional Contributor

Hey there

Thanks for that ... seems to be working like a charm for v7.52 when converting to float.

A related question. My test pc has several network drives that are sometimes offline. As I want to find that specific removable drive, I was planning to just make a drive count and then look at each of them.

This doesn't work for offline network drives, as I can't get that info. Is there a way to disregard the network drives?

I can see the drive type. Problem is, that I have no idea what they
are. I am guessing they specify whether it is removable, fixed,
network, cd or ram drive. But is that true, and which is indicated with
each value?

A quick google search only revealed this for VBScript:

0 = Unknown

1 = Removable

2 = Fixed

3 = Network

4 = CD-ROM

5 = RAM Disk

Doesn't seem to be exactly that here, as my network drives are '4'.

Hi Anders,

You can check drive type by using the DriveType property.

Here is an example (avoiding remote drives):

function DriveTypeExample;

var i, colDrives: OleVariant;


  colDrives := aqFileSystem.Drives;

  for i := 0 to colDrives.Count-1 do


    if colDrives.Item(i).DriveType <> 4 then



TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Showing results for 
Search instead for 
Did you mean: