|
-
Sep 7th, 2004, 03:13 AM
#1
DOS - CDROM letter [Resolved - work around]
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.
Last edited by Bruce Fox; Sep 7th, 2004 at 07:34 PM.
-
Sep 7th, 2004, 01:19 PM
#2
DOS doesnt know the difference between a harddrive drive letter and a cdrom drive letter.
What OS is this?
-
Sep 7th, 2004, 04:17 PM
#3
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.
-
Sep 7th, 2004, 05:54 PM
#4
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.
-
Sep 7th, 2004, 07:01 PM
#5
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.
-
Sep 7th, 2004, 07:34 PM
#6
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:
VB Code:
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.
Last edited by Bruce Fox; Sep 7th, 2004 at 07:37 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|