Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On windows XP/7, is there a way to identify from a script (never mind the script language being used) that a disk is not a network or fixed drive?

share|improve this question
up vote 7 down vote accepted

This VBS script will do it:

dim filesys
set filesys = CreateObject("Scripting.FileSystemObject") 
Set drv = filesys.GetDrive("C")
 select case drv.DriveType 
   case 0: drtype = "Unknown" 
   case 1: drtype = "Removable" 
   case 2: drtype = "Fixed" 
   case 3: drtype = "Network" 
   case 4: drtype = "CD-ROM" 
   case 5: drtype = "RAM Disk"  
end select
 MsgBox "The specified drive is a " & drtype & " type disk."

Reference - DevGuru

share|improve this answer
+1 for a concise and useful little piece of code. Sticking this in my code library. – TristaanOgre Jun 20 '11 at 14:53

Here's how you might do this using WinTask and the Win32 API GetDriveTypeA.

' GetDriveType
' Author: Joe Strazzere

dim a as unsigned    
dr$ = inputbox$("Enter the drive","GetDriveType","C:")    
a   = External("kernel32","GetDriveTypeA",dr$)

Select Case a

case 1    
  msgbox("Drive "+dr$+" was not found!",0,"GetDriveType")

case 2    
  msgbox("Drive "+dr$+" is a removable drive",0,"GetDriveType")

case 3    
  msgbox("Drive "+dr$+" is a fixed drive",0,"GetDriveType")

case 4    
  msgbox("Drive "+dr$+" is a network drive",0,"GetDriveType")

case 5    
  msgbox("Drive "+dr$+" is a CD-ROM drive",0,"GetDriveType")

case 6    
  msgbox("Drive "+dr$+" is a RAM drive",0,"GetDriveType")

case else    
  msgbox("I just don't know!",0,"GetDriveType")


share|improve this answer
Thanks for the formatting help, Jeff. – Joe Strazzere Jun 21 '11 at 11:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.