• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1340
  • Last Modified:

Need code to detect CDRom drive letter? All Windows Versions.....


Good evening/morning/afternoon.

Been a while since I haev been using this site, but it has always been a great source of answers.

I am creating a batch file, and I need to be able to (using a simple line of code) to accesss the systems registry, and automatically detect the first CDRom drive letter. I would like for the batch file to automatically be able to use the info it polls frm the system. The batch file will actually be installing programs, and creatinga directory on the c drive. Where this information will be necessary, is so that it can copy from  (drive letter ) to the c:\(directory of coice).

I dont mind what kind of code is used. If it is something that can be incorporated into a DOS batch file, that would be ideal. If not I can probably change my type of setup file to some sort of self extracting file, that can execute my programs.

I look forward to the great answersr you guys will provide.
0
johnb6767
Asked:
johnb6767
3 Solutions
 
wparrottCommented:
What version of Windows are you running this batch file on? 9x/Me, 2K/XP?
0
 
wparrottCommented:
This link will take you to an example using VB code:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;291575

This one uses VBA and will allow you to return the drive letter as a string:

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q180/7/66.asp?id=180766&SD=MSKB&NoWebContent=1

Not exactly sure how either of these could be used in a batch file but if you want help using VB script to determine the drive letter check here:

http://www.winnetmag.com/Article/ArticleID/7825/7825.html

and here:

http://www.winnetmag.com/Article/ArticleID/7992/7992.html

Hope this helps...
0
 
suramsureshbabuCommented:
0
 
fluidsmgmtCommented:
you could try this:

if exist d:\autorun.inf goto DDRIVE
if exist e:\autorun.inf goto EDRIVE
if exist f:\autorun.inf goto FDRIVE

etc, etc,.

that is, assuming you have an autorun on the cd that's in there.

Hope this helps.
0
 
DukeJCommented:
For WinNT
START /WAIT REGEDIT /E %TEMP%.\CDROM1.REG "HKEY_LOCAL_MACHINE\SYSTEM\DISK"
REM Find the CD-ROM drives and parse the strings using a subroutine
FOR /F "tokens=*" %%A IN ('TYPE %TEMP%.\CDROM1.REG ^| FIND /I "\\Device\\CdRom"') DO CALL :ParseNT4 %%A

For Win2000

SET Temp1=%Temp%.\%~n0%Random%1.reg
SET Temp2=%Temp%.\%~n0%Random%2.reg
START /WAIT REGEDIT /E %Temp1% "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"
TYPE %Temp1% > %Temp2%
TYPE %Temp2% | FIND "\\DosDevices\\" | FIND /V "\\DosDevices\\A:" | FIND "=hex:5c," > %Temp1%
FOR /F "tokens=3 delims=\:" %%A IN (%Temp1%) DO CALL :ParseW2K %%A

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now