Results 1 to 6 of 6

Thread: DOS - CDROM letter [Resolved - work around]

  1. #1

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    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.

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961
    DOS doesnt know the difference between a harddrive drive letter and a cdrom drive letter.

    What OS is this?

  3. #3

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    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.

  4. #4
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961
    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.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    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.

  6. #6

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    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:
    1. Option Explicit
    2.  
    3. Dim objFSO     'File System Object
    4. Dim objArgs     'Arguments
    5.  
    6. 'Set Objects
    7. Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
    8. Set objArgs = WScript.Arguments
    9.  
    10. If objArgs.Count <> 0 Then
    11.     msgbox objFSO.GetFolder("\") & objArgs(0)
    12. Else
    13.     MsgBox "No FileName was given"
    14. End If
    15.  
    16. Set objFSO = Nothing
    17. 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
  •  



Click Here to Expand Forum to Full Width