Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Help With A Batch File.  (Read 5440 times)

0 Members and 1 Guest are viewing this topic.

LAIN1987

    Topic Starter


    Starter

    • Experience: Familiar
    • OS: Windows 7
    Help With A Batch File.
    « on: January 05, 2017, 08:28:33 PM »
    Hello,
              I am new at creating batch files and am having a bit of trouble. what i am trying to do is build a batch that will basically copy the contents of 3 different files and paste them to a location on my network. i have come up with a CMD line code that will do the job but when i attempt to build this into a batch file it fails on my command. my code i am trying to use is as follows.

    for /f %H in (hostnames.txt) do @robocopy /COPYALL /E "\\source" "\\%H\c$\destination"

    i want this code to run 3 times copying 3 different files to 3 different locations from 3 different locations. any help would be appreciated. if you need more info feel free to ask.

    Salmon Trout

    • Guest
    Re: Help With A Batch File.
    « Reply #1 on: January 06, 2017, 12:44:08 AM »
    In a batch script, you need 2 percent signs in FOR variables, but only one at the prompt. So change %H to %%H.

    LAIN1987

      Topic Starter


      Starter

      • Experience: Familiar
      • OS: Windows 7
      Re: Help With A Batch File.
      « Reply #2 on: January 08, 2017, 03:27:06 PM »
      Thanks for the help on that, one more question i added the extra % and that seemed to work baring the attached image. basicaly CMD is showing that the destination is not found. when i run the command outside of the batch file it runs fine. any ideas?



      [attachment deleted by admin to conserve space]

      Salmon Trout

      • Guest
      Re: Help With A Batch File.
      « Reply #3 on: January 08, 2017, 03:32:33 PM »
      Maybe run the batch as administrator?
      Also check that the folders shown actually exist


      LAIN1987

        Topic Starter


        Starter

        • Experience: Familiar
        • OS: Windows 7
        Re: Help With A Batch File.
        « Reply #4 on: January 08, 2017, 03:59:03 PM »
        location does exist as i am able to push these files using just the solo command outside of the batch file. as for admin attempted while logged in as admin on system still no go just getting the error inside the image provided. my goal here is to basically push 3 folders/files to a group of pc's on a network streamlining the process so i dont need to move the files/folders manualy if that gives any insight to aid in this endeavor

        Squashman



          Specialist
        • Thanked: 134
        • Experience: Experienced
        • OS: Other
        Re: Help With A Batch File.
        « Reply #5 on: February 11, 2017, 11:43:03 PM »
        Looking at your screenshot I can see plain as day that you did not double BOTH of the percent symbols.

        Salmon Trout

        • Guest
        Re: Help With A Batch File.
        « Reply #6 on: February 12, 2017, 02:36:56 AM »
        Me too.