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,563 of 68,980    |
|    JJ to Peter    |
|    Re: How to Test Whether a Drive Exists    |
|    07 Jun 20 22:01:10    |
      From: jj4public@vfemail.net              On Fri, 5 Jun 2020 19:04:34 -0700 (PDT), 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.              Use this.              @echo off       setlocal       set drive=z       if not exist %drive%:\ (        echo Drive is not found/connected, or has no drive letter assigned.        pause        goto :eof       )       pushd %drive%:\       if errorlevel 1 (        rem the above PUSHD command will show the error message whether        rem the drive is bitlocker-locked, or is inaccessible.        pause        goto :eof       )       popd       echo Drive is connected and accessible.       pause              --- 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