PC Review Forums Newsgroups Windows 2000 Microsoft Windows 2000 CMD Promt Found logical drive letter

Reply

Found logical drive letter

 
Thread Tools Rate Thread
Old 02-07-2003, 06:43 PM   #1
Dada
Guest
 
Posts: n/a
Default Found logical drive letter


Hi,
i must use the logical letter where exist a specificated directory. It's
possible?

Es for run F:\app1 i must know the drive letter first., therefore:
c:\cd 'Drive letter'
app1

Thanks


  Reply With Quote
Old 02-07-2003, 07:36 PM   #2
Mark Zbikowski \(MSFT\)
Guest
 
Posts: n/a
Default Re: Found logical drive letter

If you are using a .CMD file, you can have a section that extracts the drive
letter of an argument and returns it in a variable. Here's an example:

@echo off
rem Batch file that echos the drive letter on all it's parameters
rem Yes, it's the hard way

:top
if "%1" == "" goto :eof

call :GetDriveLetter %1

echo Drive letter of %1 is %result%

shift
goto :top

:GetDriveLetter

set result=%~d1
goto :eof



"Dada" <polux@libero.it> wrote in message
news:eRlw9jLQDHA.3020@TK2MSFTNGP10.phx.gbl...
> Hi,
> i must use the logical letter where exist a specificated directory. It's
> possible?
>
> Es for run F:\app1 i must know the drive letter first., therefore:
> c:\cd 'Drive letter'
> app1
>
> Thanks
>
>



  Reply With Quote
Old 02-07-2003, 09:36 PM   #3
Scot Wiedenfeld
Guest
 
Posts: n/a
Default Re: Found logical drive letter

I don't know if I'm exactly clear on what you're asking. From what I gather
you want to "Use the logical letter where exist a specified (spelling
corrected) directory".

Perhaps the SUBST command?

C:\>subst /?
Associates a path with a drive letter.

SUBST [drive1: [drive2:]path]

<snip>

Example:

C:\>SUBST Z: C:\mydirectory

Just my 2.0134 cents worth (tax included)
Scot Wiedenfeld

"Dada" <polux@libero.it> wrote in message
news:eRlw9jLQDHA.3020@TK2MSFTNGP10.phx.gbl...
> Hi,
> i must use the logical letter where exist a specificated directory. It's
> possible?
>
> Es for run F:\app1 i must know the drive letter first., therefore:
> c:\cd 'Drive letter'
> app1
>
> Thanks
>
>



  Reply With Quote
Old 03-07-2003, 05:36 PM   #4
Marty List
Guest
 
Posts: n/a
Default Re: Found logical drive letter


If you don't know what the drive letter is, then your script isn't going to
be able to figure it out by using magic. Maybe the drive letter is stored
in the registry or in a shortcut?

To change to a new drive, just enter the drive letter and the colon, like
this:

C:\>f:

F:\>


Or, you can use "cd /d" like this:

C:\>cd /d F:\MyDIR

F:\MyDir>start MyAPP

F:\MyDir>exit


  Reply With Quote
Old 04-07-2003, 08:35 PM   #5
Mark V
Guest
 
Posts: n/a
Default Re: Found logical drive letter

Dada wrote in news:Oc6iYsTQDHA.3768@tk2msftngp13.phx.gbl:

> Excuse me for my english and for my unclear mex.
> I must run a application (for ex. named MyAPP) a server using a
> .BAT file, but i don't know the logical letter (C: or D: or ecc..)
> where this application is saved; i know the directory name only
> (for ex named MyDIR). Ex, if must run MyAPP in MyDIR directory but
> i don't know the disk location, how make to run it?
>
> Ex of promt cmd:
>
> C:\ <logical letter>: (i digit the letter driver where
> application is saved (??? I don't know..))
> <logical letter> cd\ (i go to directory)
> <logical letter> cd MyDIR
> <logical letter> start MyAPP (I run application and exit)
> <logical letter> exit
>
> How make for found <logical letter> where MyDIR is saved?


If I understand correctly then why not just try them all?
IF EXIST C:\mydir\myapp.exe START C:\mydir\myapp.exe
IF EXIST D:\mydir\myapp.exe START D:\mydir\myapp.exe
IF EXIST E:\mydir\myapp.exe START E:\mydir\myapp.exe
...
IF EXIST Z:\mydir\myapp.exe START Z:\mydir\myapp.exe

Or do the same using a FOR statement.

Or other variations of testing all possible
drives/directories/executable file.



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off