PC Review


Reply
Thread Tools Rate Thread

Access drive by name

 
 
Howard Brazee
Guest
Posts: n/a
 
      15th Feb 2007
Sometimes a removable drive on a networked computer has a different
drive letter than I had the previous time.

How can I write a cleaner batch file that accesses a drive by name? I
know the name, but the letter might be variable.

The following code works - but it is ugly code:

echo on
set mydrive=D:
dir %mydrive% 2>NUL | FIND /i "Brazee" >NUL
@If ErrorLevel 1 goto :tryE
@If not ErrorLevel 1 goto :foundIt
@If ErrorLevel 1 goto :Finale
pause You should not get here

:TryE
set mydrive=E:
dir %mydrive% 2>NUL | FIND /i "Brazee" >NUL
@If ErrorLevel 1 goto :tryF
@If not ErrorLevel 1 goto :foundIt
@If ErrorLevel 1 goto :Finale
pause You should not get here

:TryF
set mydrive=E:
dir %mydrive% 2>NUL | FIND /i "Brazee" >NUL
@If ErrorLevel 1 goto :tryG
@If not ErrorLevel 1 goto :foundIt
@If ErrorLevel 1 goto :Finale
pause You should not get here

:TryG
set mydrive=G:
dir %mydrive% 2>NUL | FIND /i "Brazee" >NUL
@If ErrorLevel 1 goto :tryH
@If not ErrorLevel 1 goto :foundIt
@If ErrorLevel 1 goto :Finale
pause You should not get here

:TryH
echo failure
goto :finale

:foundIt
pause foundit
:Finale
pause exit
 
Reply With Quote
 
 
 
 
Newbie Coder
Guest
Posts: n/a
 
      15th Feb 2007
This is not a newsgroup for writing batch files - sorry

XP has a bug with flash drives & assigning drive letters. Try assigning a
letter like Z to it & see it that holds it.

--
Newbie Coder
(It's just a name)


 
Reply With Quote
 
Howard Brazee
Guest
Posts: n/a
 
      16th Feb 2007
On Thu, 15 Feb 2007 20:44:47 -0000, "Newbie Coder"
<(E-Mail Removed)> wrote:

>This is not a newsgroup for writing batch files - sorry


It's as close as I can find.

>XP has a bug with flash drives & assigning drive letters. Try assigning a
>letter like Z to it & see it that holds it.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't access external drive on XP - previous Vista Boot Drive mariaceleste358@gmail.com Windows Vista General Discussion 3 22nd Aug 2008 05:29 PM
Access XP data drive using Vista Ult (XP drive=slave drive only NO John C (Go Packers!) Windows Vista Administration 0 23rd Jun 2008 08:38 PM
How to access a local drive (including removable drive) in a terminal server session programmatically? Bill Nguyen Microsoft VB .NET 1 23rd May 2007 03:19 AM
Hard Drive failed - can't access encrypted files on data drive =?Utf-8?B?U2NvdHQ=?= Windows XP General 10 2nd Jan 2006 04:46 AM
Hard drive runs at random, but no light and no record of drive/file access Carl. Computer Hardware 1 6th Feb 2005 06:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:57 PM.