1.

Solve : is it possible ???

Answer»

Hello again,

I'd like to know if it is possible to attribuate a DRIVE letter to a CD-ROM FROM a CD-ROMPlease explain more clearly what you mean. Do you mean "Can you write a batch file which you burn on a CD-ROM and when it is run it knows what the drive letter of the CD-ROm drive is?"

Quote from: Dias de verano on MARCH 31, 2008, 01:33:18 PM

Please explain more clearly what you mean. Do you mean "Can you write a batch file which you burn on a CD-ROM and when it is run it knows what the drive letter of the CD-ROm drive is?"

something like that... and then use that letter in other batchs.... like EX.: %cdrom% where cdrom would be "w:\"

then use that letter in other batchs....A batch file always knows its own name, which is contained in the variable %0 (a percent sign and a zero)

You can get the drive letter using %~D0.

It has a colon but you can extract the bare letter as you will see below

here is location.bat

Code: [Select]@ECHO off
set cdrom=%~d0
echo this is my drive %cdrom%

Once that has been run the drive letter and colon are contained in the variable %cdrom% which is visible to the prompt and to other batch files

here is another.bat

Code: [Select]@echo off
echo this batch file can see the variable
echo drive is %cdrom%

Here is what happens when I ran them

Code: [Select]E:\>location.bat
this is my drive E:
E:\>echo %cdrom%
E:

E:\>echo %cdrom:~0,1%
E

E:\>another.bat
this batch file can see the variable
drive is E:

Quote from: Dias de verano on March 31, 2008, 02:29:03 PM
A batch file always knows its own name, which is contained in the variable %0 (a percent sign and a zero)

You can get the drive letter using %~d0.

It has a colon but you can extract the bare letter as you will see below

here is location.bat

Code: [Select]@echo off
set cdrom=%~d0
echo this is my drive %cdrom%

Once that has been run the drive letter and colon are contained in the variable %cdrom% which is visible to the prompt and to other batch files

here is another.bat

Code: [Select]@echo off
echo this batch file can see the variable
echo drive is %cdrom%

Here is what happens when I ran them

Code: [Select]E:\>location.bat
this is my drive E:
E:\>echo %cdrom%
E:

E:\>echo %cdrom:~0,1%
E

E:\>another.bat
this batch file can see the variable
drive is E:



Thanx !!

It does work !! in the other Main I putted %1[path]


Discussion

No Comment Found