Solved

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

Posted on 2004-09-06
7
1,318 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
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 168 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 166 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 166 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
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.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now