Batch file to de-fragment, backup, then shutdown?


  1. Posts : 1
    Windows 7 Home Premium SP1 x64
       #1

    Batch file to de-fragment, backup, then shutdown?


    Hey guys,

    Is there a way I can create a batch file so de-fragment my hard drive, once that has finished, backup to an external hard drive, and then one that has finished shut down the PC?

    Thanks,

    JPiiONEFOURONE
      My Computer


  2. Posts : 19,383
    Windows 10 Pro x64 ; Xubuntu x64
       #2

    Hi,

    The first two are easy enough, but I've had some trouble getting a SHUTDOWN to happen after a backup has run - it seems to execute the shutdown during the other commands.

    For the defragmentation and backup, try this - lets assume you want to backup from E:\Work and E:\Music to Z:

    Code:
    defrag E: /U /V
    robocopy E:\Work Z:\Backup\Work /E /MIR /R:3 /W:10
    robocopy E:\Music Z:\Backup\Music /E /MIR /R:3 /W:10
    To see more help with these commands, in a CMD window type:
    Code:
    defrag /?
    robocopy /?
    shutdown /?
    And some light bedtime reading:
    ROBOCOPY - Create Backup Script

    Regards,
    Golden
      My Computer


  3. Posts : 2,171
    Windows 7 Ultimate x64
       #3

    Maybe prepending the last robocopy command with start /wait would prevent that shutdown before the backup is finished.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 05:27.
Find Us