Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,559 of 68,980    |
|    dr.j.r.stockton@gmail.com to Peter    |
|    Re: How to Test Whether a Drive Exists    |
|    06 Jun 20 02:07:58    |
   
   On Saturday, 6 June 2020 03:04:36 UTC+1, Peter wrote:   
   > How can I test in a batch file whether an external USB drive does not exist   
   because: 1) it’s not currently connected to the PC or 2) it is connected but   
   it’s locked by a program such as BitLocker (in Windows 10)?   
   >    
   > If I use the usual “if not exist d:” line it will say the drive does not   
   exist in either case above. How can I distinguish between 1) the drive is not   
   connected or 2) the drive is connected but it’s locked?   
   >    
   > FYI, when a drive is locked by Bitlocker it will still be listed in Windows   
   Explorer however “if exist” will say that it does not exist.   
      
      
   Have you tested other DOS commands to see whether any of them   
   give different replies for the different cases? That seems   
   unlikely, but it's worth trying because trying is so easy.   
      
   Batch can call, with CScript, VBScript or JScript. In a recent   
   thread here, I showed how a Batch file can call JScript and one   
   way of getting an answer back. I have a Batch file calling   
   JScript which contains the following code   
      
      
   fso = new ActiveXObject("Scripting.FileSystemObject")   
      
       
   function Drive() { var D = fso.getDrive   
    new Enumerator(fso.G   
   tFolder(sFolder).Files).item().Drive ) ; Rite("    
   Drive is " + sFolder + "\n" +    
   PaddIt(D.AvailableSpace, 16) + " AvailableSpace\n"    
    PaddIt(D.DriveLetter, 16) + " DriveLetter\n"   
   + PaddIt(D.DriveType,    
   16) + " DriveType\n" + Padd   
   t(D.FileSystem, 16) + " FileSystem\n" +    
   PaddIt(D.FreeSpace, 16) + " FreeSpace\n"    
    PaddIt(D.IsReady, 16)    
    + " IsReady\n" + PaddIt(D.Path, 16   
    + " Path\n" + Pa   
   dIt(D.SerialNumber, 16) + " SerialNumber\n" +    
   PaddIt(D.ShareName, 16) + " ShareName\   
   n" + PaddIt(D.TotalSize, 16) + "   
   TotalSize\n" + PaddIt(D.VolumeName, 16) +   
   " VolumeName\n\n" ) }   
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
       
   function Drves() { var en, D, S = " Drives :"    
    for (en = new Enumerator(fso.Drives) ; !en.atEnd() ; en.move   
   ext()) S += SP + en.item().DriveLetter    
    Rite(S + NL) }    
      
   and can give the following outputs   
      
    Drive is F:   
    420364288 AvailableSpace   
    F DriveLetter   
    1 DriveType   
    FAT FileSystem   
    420364288 FreeSpace   
    true IsReady   
    F: Path   
    -1023875854 SerialNumber   
    ShareName   
    519274496 TotalSize   
    STOCKTON JR VolumeName   
      
    Drives : C D E    
      
       
   It seems to me possible that one or both of those outputs MIGHT   
   yield the detection that you want.    
      
      
   --    
    (c) John Stockton, near London, UK. Using Google Groups. |   
    Mail: J.R.""""""""@physics.org - or as Reply-To, if any. |   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca