1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

How to write a drive-independent file path

Discussion in 'Other PC Software' started by theo54nz, 2004/12/22.

Thread Status:
Not open for further replies.
  1. 2004/12/22
    theo54nz

    theo54nz Inactive Thread Starter

    Joined:
    2004/12/02
    Messages:
    9
    Likes Received:
    0
    I am trying to write a small dos .bat file which I want to copy on to a CD for the ease of copying files from the CD to a hard drive.
    But, not all CD drives are D:\ drives, they may as well be E:\ or F:\ or G:\
    Now, what should a command line in DOS look like if I want to write it for ANY drive.
    e.g "copy D:\files\*.* c:\games\" were "D" could be anything from A-Z

    Thanks :)
     
  2. 2004/12/23
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    15,174
    Likes Received:
    412
    Since the batch file will be on the CD, I don't think you have to reference the drive letter.

    i.e. copy \files\*.* c:\games\ would do.

    Although, I admit, it has been nearly a decade ago I played with batch files :eek:
     
    Arie,
    #2

  3. to hide this advert.

  4. 2004/12/23
    merlin

    merlin Inactive

    Joined:
    2003/01/07
    Messages:
    1,111
    Likes Received:
    0
    Arie is most probably correct on this one.

    "When an executable file is named on the command line (or in a batch file) without an explicit path, Dos will always first search for this file in the current directory on the current drive. If the file is not found there, Dos will then search any paths listed in the Path environmental variable. "
    (Old Testament, DOS, Chapter 5, Verse 25)

    So if you first select the CD ROM drive and then start the .bat, it should
    run OK.
    At the start of the .bat maybe add a line
    PATH ;
    ... but not sure what Path/s re-set when .bat finishes ...
    Note that you MUST first click the CD ROM drive to open it eg you cannot
    run the .bat from a Windows RUN prompt.
    regards
     
  5. 2004/12/23
    best5

    best5 Inactive

    Joined:
    2002/01/07
    Messages:
    75
    Likes Received:
    0
    hello,

    I believe you can do this using a Autorun.inf file. You may need to copy at the root directory of your CD XCOPY.EXE and XCOPY32.MOD from C:\Windows\Command just to be on the safe side and make sure that xcopy.exe will run even on a XP machine.
    You suppose to make a BAT file also :
    xcopy [source path on CD] c:\[target directory path]
    and save it as, e.g A.BAT
    To make the Autorun.inf, open a new text document and type there:

    [AutoRun]
    open=A.BAT

    and save it as AUTORUN.INF

    I've tried all these using a virtual CD and it worked. It's better to try it with
    a CD-RW - that' the real thing, of course.

    good luck and let us know how it worked

    Stefan
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.