Batch Help
Results 1 to 8 of 8

Thread: Batch Help

  1. #1
    Join Date
    Apr 2000
    Location
    Harleysville, Pa. USA
    Posts
    605

    Batch Help

    Hello.
    For backups, I use DriveImage XML which runs from the Task Scheduler with this command: "C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"D:\drive_c /s /l

    I have a 2nd hard drive that has 2 partitions, "D" and "J". After the program runs, I change the command to read J:\drive_c /s /l so it alternates week to week. Is there a way to make the batch file change the drive letter automatically after each run?

    Thank you.
    Desktop: Dell I620. Win 7 Home Premium
    Laptop 1: Toshiba, Win7 home premium
    Laptop 2: Macbook Pro

  2. #2
    Join Date
    Feb 2000
    Location
    Idaho Falls, Idaho, USA
    Posts
    18,086
    An easier alternative would be to have a batch file for each drive, and a batch file that Task Scheduler uses. Then, have the last command in each batch file copy the next batch file in the rotation to the batch file used in Task Scheduler.

  3. #3
    Join Date
    Apr 2000
    Location
    Harleysville, Pa. USA
    Posts
    605
    jdc2000. Thanks for the reply.

    I don't think I quite understand this. The only file to run would be the one that task scheduler uses so how would the other 2 run? If I put a line in the task scheduler batch file to copy one of the other batch files, how would it know to alternate? Or, am I reading this wrong?
    Thank you.
    Desktop: Dell I620. Win 7 Home Premium
    Laptop 1: Toshiba, Win7 home premium
    Laptop 2: Macbook Pro

  4. #4
    Join Date
    Mar 2009
    Location
    Arkham Asylum, Cell 13
    Posts
    11,700
    Can't you just have 2 batch files and schedule them to run every 2 weeks?

    Task1 - batchD (week 1, 3, 5, etc)
    Task2 - batchJ (week 2, 4, 6, etc)

  5. #5
    Join Date
    Feb 2000
    Location
    Idaho Falls, Idaho, USA
    Posts
    18,086
    Example:

    Backup1.bat file contents:
    C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"D:\drive_c /s /l
    copy Backup2.bat Backup.bat

    Backup2.bat file contents:
    C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"J:\drive_c /s /l
    copy Backup1.bat Backup.bat

    In Task Scheduler, use Backup.bat as the file to schedule, and start with Backup.bat as a copy of Backup1.bat

  6. #6
    Join Date
    Apr 2005
    Location
    Maryland, USA
    Posts
    17,806
    Here's one that will alternate between D: and J: all by itself, as well as record the beginning and completed date and time, (which could come in handy):
    Code:
    @echo off
    if not exist "C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt" goto Backup2D
    find "J:" "C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt">nul
    if errorlevel 1 goto Backup2J
    :Backup2D
    echo dixml.exe backup to D:\drive_c beginning on %date% at %time%>"C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt"
    "C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"D:\drive_c /s /l
    echo dixml.exe backup to D:\drive_c completed on %date% at %time%>>"C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt"
    goto End
    :Backup2J
    echo dixml.exe backup to J:\drive_c beginning on %date% at %time%>"C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt"
    "C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bC /t"D:\drive_c /s /l
    echo dixml.exe backup to J:\drive_c completed on %date% at %time%>>"C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt"
    :End
    After it has run, see the file "C:\Program Files\Runtime Software\DriveImage XML\Last_Backup.txt" for the results.

  7. #7
    Join Date
    Apr 2000
    Location
    Harleysville, Pa. USA
    Posts
    605
    Thank you all very much for the replies. Very informative. I've learned something today.
    Desktop: Dell I620. Win 7 Home Premium
    Laptop 1: Toshiba, Win7 home premium
    Laptop 2: Macbook Pro

  8. #8
    Join Date
    Apr 2005
    Location
    Maryland, USA
    Posts
    17,806

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •