Click to See Complete Forum and Search --> : DOS - CDROM letter [Resolved - work around]
Bruce Fox
Sep 7th, 2004, 03:13 AM
Hi all, non-vb time :)
1. How can I return (thru a batch file / command line) the drive letter of the CDROM, or
2. If I have a batch file resident on a CD, can I do something like 'Echo Path' and have it display the 'current path' (being the drive letter).
Scenario:
I need to pass a file as a parameter to a M$ app, and this particular app requires a full path for the param. As the file will be on CD, I don't want to 'hard' code the drive letter :).
I think I have tried all internal and external DOS commands and %systemroot% etc!
Bruce.
Dave Sell
Sep 7th, 2004, 01:19 PM
DOS doesnt know the difference between a harddrive drive letter and a cdrom drive letter.
What OS is this?
Bruce Fox
Sep 7th, 2004, 04:17 PM
XP/2000
I know that I can do it in VB, C++ or script, but I thought I could simply do it thru DOS somehow.
Bruce.
Dave Sell
Sep 7th, 2004, 05:54 PM
Originally posted by Bruce Fox
XP/2000
I know that I can do it in VB, C++ or script, but I thought I could simply do it thru DOS somehow.
Bruce.
Somehow, yes it can be done, but not on a default installation of DOS. If somehow, someone, somewhere, were to create DOS environment variables like:
CDDRIVE=E:\
or something like that, THEN DOS could use that environment variable to determine the drive letter of a CDROM.
But you will have to place a line in the user's autoexec.bat file to remain persistent.
dglienna
Sep 7th, 2004, 07:01 PM
How about the LASTDRIVE? Unless there are multiple CD drives, then the highest one is the one that you want.
this is usually in the autoexec.bat file on systems with a CD.
Bruce Fox
Sep 7th, 2004, 07:34 PM
Thanks for the replies guys,
I have a work around (using VBScript).
I did however find two examples to do it with DOS!
Both involved iterating past the alphabet.
So for anyone interested, it can be done with a few lines of DOS (which is what I was trying to avoid).
Here is the test Script:
Option Explicit
Dim objFSO 'File System Object
Dim objArgs 'Arguments
'Set Objects
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
If objArgs.Count <> 0 Then
msgbox objFSO.GetFolder("\") & objArgs(0)
Else
MsgBox "No FileName was given"
End If
Set objFSO = Nothing
Set objArgs = Nothing
The trick was using GetFolder without specifying a drive/path
And after all that I'm probably not going to use it anyway :)
Bruce.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.