Announcement

Collapse
No announcement yet.

Batch file copy from cd?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Batch file copy from cd?

    Hi

    Im new to this, and have searched the forums but seem unable to achieve my goal.
    I've written a very simple batch file using xcopy to copy a folder from the My Documents folder to the root of C, then run an exe from within the copied folder.
    This works fine if the starting location drive letter is defined in the batch file.
    However, I need to perform this action from the CD Rom drive from different machines, and seeing as the drive letters may vary, I cannot specify the starting location drive letter.
    Is there a way around this?

    TIA

  • #2
    Why does this need to be done from different machines?
    Is it possible to SHARE a CD ROM drive (or even copy the CD's contents to a HDD and create a SHARE) then you would be able to use a UNC path in the coping script.
    1 1 was a racehorse.
    2 2 was 1 2.
    1 1 1 1 race 1 day,
    2 2 1 1 2

    Comment


    • #3
      Batch file copy from cd?

      Hi

      Thanks for the reply.

      The reason for this script is because I'm creating an installation CD with various functions, that will be used by several people to install on different machines, different locations.

      The syntax im sure will be very simple, I just need someone that knows batch commands to point me in the right direction.

      To recap, I have a CD that I need to copy a folder and all of its contents to C: then run an exe from within that folder.

      If anyone could help I would be most appriciative.

      TIA

      Comment


      • #4
        Use %systemdrive% variable instead of stating C: explicitly.

        Type "set" in a command prompt window to get more variables (TEMP, TMP, SYSTEMROOT...)
        Guy Teverovsky
        "Smith & Wesson - the original point and click interface"

        Comment


        • #5
          Hi

          Thanks again for the reply, but it still doesnt help.

          Heres an example of the code im using at the moment:

          rem

          cd c:\
          md Example

          cd c:\Example

          xcopy "C:\Documents and Settings\User\My Documents\Test\Example\SpaceMonger.exe" "c:\Example" /s

          c:\Example\SpaceMonger.exe


          As you can see, it creates an empty 'Example' folder on the root of C:, then copies the contents of 'Example' from the 'My Documents folder into the newly created folder on C:, and executes it.
          I've created a shortcut to the Batch file, and this works fine using the above syntax.

          However, once its burnt on CD (the shortcut to the Batch file is on an autorun html page with other shortcuts to other apps), I obviously cannot specify the path as C: in xcopy where its coming from (where its copying to will remain constant).
          The problem is that CD Rom drive letters will vary, so is there a way to tell it to look in the "<CD Rom>\Test\Example" folder? I.E., some syntax that specifies the CD Rom on any machine, irrespective of its drive letter?

          I hope this has cleared up my query and what it is I require. If anyone has any answers I would be most grateful.

          TIA

          Comment


          • #6
            However, I need to perform this action from the CD Rom drive from different machines, and seeing as the drive letters may vary, I cannot specify the starting location drive letter.
            Is there a way around this?
            Yes, there is a standard trick for this. The full path of the script is given by %0. So, %0\.. refers to the folder it is in. For example, dir %0\.. lists the contents directory where the script is located. You can use this to navigate around the folder structure of the CDROM.

            Comment


            • #7
              Solved!

              Thanks to those that replied.
              I've now solved it; it was as simple as ommiting the path altogether, so instead of:

              rem

              cd c:\
              md Example

              cd c:\Example

              xcopy "C:\Documents and Settings\Wilcee\My Documents\Test\Example\SpaceMonger.exe" "c:\Example" /s

              c:\Example\SpaceMonger.exe


              I changed the script to the following:

              rem

              cd c:\
              md Example

              cd c:\Example

              xcopy "Example\SpaceMonger.exe" "c:\Example" /s

              c:\Example\SpaceMonger.exe


              It now works like a charm, no matter what CD Rom I use & no matter what the drive letter is

              Comment

              Working...
              X