1.

Solve : CDROM in Batch File?

Answer»

Hello,

I have looked for a forum search fuctino and I also went through many pages to see if I could FIND my answer. I am wondering how I within a batch file tell it to use whater drive letter the cdrom is, the batch file will be ran on a laptop so it will only have 1 batch file but I cannot figure out how to get it to use whatever drive letter it is other than just setting it to D:\ and making sure all the laptops cdrom drive is SET to D:\. Is their a way for a batch to use whatever drive letter the cdrom might be? Below is the set drive that is D:\ would like to get that changed to use whatever drive letter the cdrom might be. I have tried SET PATH=%CDROM% and changing the d:\ifly.exe to %CDROM%:\ifly.exe but it does not work. Also a little ways down it calls for the cdrom drive again. If it put it to D:\ it will work just fine.

Code: [Select]ECHO 1 - Run ifly Installation Program
ECHO 2 - Update Manuals
ECHO 3 - EXIT
ECHO.
SET /P M=TYPE 1, 2 or 3 then press ENTER:
IF %M%==1 GOTO START
IF %M%==2 GOTO MANUALS
IF %m%==3 GOTO EXIT
:START
d:\ifly.exe
GOTO MENU
:MANUALS
rmdir c:\manualsupport /s /q
mkdir c:\manualsupport
xcopy /E d:\manualsupport\*.* c:\manualsupport\
xcopy /E /Y c:\manualsupport\nircmd\*.* c:\windows\
xcopy /E /Y c:\manualsupport\Shortcut\*.* c:\windows\
start c:\manualsupport\filespresent.bat
exit
:EXIT
exitI have found a generic way of doing it

having

Path=D:\;E:\;F:\;G:\; etc..

removing

Code: [Select]ifly.exe
GOTO MENU
:MANUALS
rmdir c:\manualsupport /s /q
mkdir c:\manualsupport
xcopy /E manualsupport\*.* c:\manualsupport\

seems to work testing now to make sure it all works.
C:\test>type chtoE.bat
Code: [Select]cd C:\test
E:
dir a*.txt
C:

Output:

C:\test>chtoE.bat

C:\test>cd C:\test

C:\test>E:

E:\>dir a*.txt
Volume in drive E is My Book
Volume Serial Number is 0850-D7C5

Directory of E:\

11/10/2009 03:24 PM 36 abc.txt
11/13/2009 01:21 PM 198 abc2.txt
11/17/2009 05:36 PM 290 abc5.txt
12/21/2009 01:29 PM 144 arc.txt
12/24/2009 09:58 PM 269 awkinfile.txt
12/23/2009 10:56 PM 39 awlinfile.txt
6 File(s) 976 bytes
0 Dir(s) 139,043,950,592 bytes free

E:\>C:

C:\test>So I finally found my answer, all I had to do was remove the d:\ifly.exe so it is what is below and remove the d: to what it is below. all is WORKING now.

Code: [Select]ECHO 1 - Run ifly Installation Program
ECHO 2 - Update Manuals
ECHO 3 - Exit
ECHO.
SET /P M=Type 1, 2 or 3 then press ENTER:
IF %M%==1 GOTO START
IF %M%==2 GOTO MANUALS
IF %m%==3 GOTO EXIT
:START
ifly.exe
GOTO MENU
:MANUALS
rmdir c:\manualsupport /s /q
mkdir c:\manualsupport
xcopy /E \manualsupport\*.* c:\manualsupport\
xcopy /E /Y c:\manualsupport\nircmd\*.* c:\windows\
xcopy /E /Y c:\manualsupport\Shortcut\*.* c:\windows\
start c:\manualsupport\filespresent.bat
exit
:EXIT
exit



Discussion

No Comment Found