?
Solved

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

Posted on 2004-09-06
7
Medium Priority
?
1,335 Views
Last Modified: 2008-01-09

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
Comment
Question by:johnb6767
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Expert Comment

by:wparrott
ID: 11993985
What version of Windows are you running this batch file on? 9x/Me, 2K/XP?
0
 
LVL 7

Accepted Solution

by:
wparrott earned 672 total points
ID: 11994031
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
 
LVL 7

Assisted Solution

by:suramsureshbabu
suramsureshbabu earned 664 total points
ID: 11994360
0
 

Expert Comment

by:fluidsmgmt
ID: 11997677
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
 

Assisted Solution

by:DukeJ
DukeJ earned 664 total points
ID: 11998119
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question