1

The following is my nightly_backup.bat file, scheduled to run every night at 11pm.

But though it does the backups ok, I never find it paused in the morning, like I expect it.

echo off
ROBOCOPY C:\PRIMARY  B:\BACKUP\PRIMARY\  /e /NFL /NDL   
ROBOCOPY B:\BACKUP\    E:\BACKUP\  /e /NFL /NDL   
ROBOCOPY B:\ARCHIVE\   E:\ARCHIVE\  /e /NFL /NDL   



rem  Backup favorites-
ROBOCOPY C:\Users\douglaskbell\Favorites  C:\BACKUP\FAVORITES\  /e /NFL /NDL   
ROBOCOPY C:\Users\douglaskbell\Favorites  B:\BACKUP\FAVORITES\  /e /NFL /NDL   
ROBOCOPY C:\Users\douglaskbell\Favorites  E:\BACKUP\FAVORITES\  /e /NFL /NDL   

DATE /T
pause

:EXIT
DATE /T
3
  • Well the code as it stands should pause. So, the question becomes how have you scheduled it to run? I'm assuming task scheduler, but what exact settings have you used? Do you have it running as the logged on user, as system, with highest priveleges, etc? It likely is pausing, but you are running the script in the background (as SYSTEM or some other user) so you don't see it. If you look in task manager, you'll see a cmd.exe process running but you won't see it. If you were running this as the logged on user, it would probably fail due to UAC. Commented Nov 20, 2017 at 3:12
  • 1
    pause is an internal command of cmd.exe, it's not a DOS command. DOS and Windows cmd are not the same thing
    – phuclv
    Commented Nov 20, 2017 at 3:54
  • The "pause" command is inherently interactive. It's not surprising that it is ignored in a non-interactive environment, such as when the user is not logged in.
    – kreemoweet
    Commented Nov 20, 2017 at 22:46

1 Answer 1

0

Assuming you've scheduled this via the Windows Task Scheduler, try scheduling the task to run with the account of the user you're logging in as (assuming you have the correct permissions to run robocopy). If, for example, you're scheduled task's security options are configured for SYSTEM, you will not see the paused cmd window.

Test this with a new .bat:

echo off
DATE /T >> C:\log.txt
pause

Configure a scheduled task for this script using your username. Run it, and you'll see the creation of C:\log.txt along with a paused cmd window. If you delete this log file, change the scheduled task to run as SYSTEM and run the task, you'll see the creation of the log file, but no paused cmd window.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .