Page 1 of 1

Bat start every day on 1:00am and protectionans set autostrt

Posted: 13 May 2015 13:23
by Krump
I have little script Autorun.bat:

Code: Select all

@echo off
%~d0
cd %~d0%~p0%

AT 01:00 /EVERY:pn,wt,sr,cz,pt,so,n %~dp0BACKUP.bat


It works but I must do protection for this. I want to if backup can't start in this time, because for example computer was off. Then Backup.bat start with nearest run system.
Second what I need is autorun.bat autostarting every time when backup disk will input to usb. AUTORUN.bat is in this disk (example directory B:\Autorun.bat)

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 13 May 2015 13:46
by Squashman
Krump wrote:It works but I must do protection for this. I want to if backup can't start in this time, because for example computer was off. Then Backup.bat start with nearest run system.

The AT command cannot do that. Even looking at schtasks.exe, I do not see an option for that. The only way to do that is to create the task with Windows Task Scheduler.

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 13 May 2015 13:50
by Krump
So only way for it is a write script in for example c++?

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 13 May 2015 14:06
by Squashman
Krump wrote:So only way for it is a write script in for example c++?

No clue. This is not a c++ forum. Did not think C++ was a scripting language either.

You can create the task with Windows Task Scheduler and export it. It exports as an xml file. You can then use schtasks from the command line to import it.

Not sure about the AutoRun either. I thought that was disabled by default now.

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 14 May 2015 11:11
by Krump
Ehhh... Very shame... Nobody have any idea? I know that backup programs hve someone like that.

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 14 May 2015 11:29
by Squashman
Windows does have the capability you are looking for, just not in the way you want to use it.

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 14 May 2015 13:59
by ShadowThief
Store the time of last run in a file and set up a scheduled task that will check the file's contents upon boot?

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 15 May 2015 06:24
by miskox
According to this https://technet.microsoft.com/en-us/lib ... 22178.aspx you have:

Code: Select all

Run task as soon as possible after a scheduled start is missed

If this setting is checked, the Task Scheduler service will start the task if the task was scheduled to run at a certain time, but for some reason (for example, the computer was turned off or the Task Scheduler service was busy) the task was not activated. The Task Scheduler service will not start the task immediately after the task was missed. By default the service waits ten minutes before starting the missed task.


Saso

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 15 May 2015 12:45
by Krump
Ok, but how write it in a script? Dos, Script, PowerShell script, c or c++...

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 15 May 2015 12:49
by Squashman
Krump wrote:Ok, but how write it in a script? Dos, Script, PowerShell script, c or c++...

I told you how in a previous post. You need to at least create the task ONCE in the normal Windows Task Scheduler. Then you can Export that task. It outputs as an xml file. You can then use schtasks.exe in a batch file to import that XML file onto any computer you want.

Re: Bat start every day on 1:00am and protectionans set auto

Posted: 30 Oct 2015 10:12
by Samir
A little late, but I execute batches at specific times using the following code:

Code: Select all

:START
PING -n 60 127.0.0.1 > NUL
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"==" 1:00" GOTO START

ECHO WHATEVER YOU WANT TO EXECUTE