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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Krump
Posts: 45
Joined: 02 Dec 2014 14:53

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

#1 Post by Krump » 13 May 2015 13:23

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)

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 13 May 2015 13:46

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.

Krump
Posts: 45
Joined: 02 Dec 2014 14:53

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

#3 Post by Krump » 13 May 2015 13:50

So only way for it is a write script in for example c++?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#4 Post by Squashman » 13 May 2015 14:06

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.

Krump
Posts: 45
Joined: 02 Dec 2014 14:53

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

#5 Post by Krump » 14 May 2015 11:11

Ehhh... Very shame... Nobody have any idea? I know that backup programs hve someone like that.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#6 Post by Squashman » 14 May 2015 11:29

Windows does have the capability you are looking for, just not in the way you want to use it.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

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

#7 Post by ShadowThief » 14 May 2015 13:59

Store the time of last run in a file and set up a scheduled task that will check the file's contents upon boot?

miskox
Posts: 630
Joined: 28 Jun 2010 03:46

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

#8 Post by miskox » 15 May 2015 06:24

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

Krump
Posts: 45
Joined: 02 Dec 2014 14:53

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

#9 Post by Krump » 15 May 2015 12:45

Ok, but how write it in a script? Dos, Script, PowerShell script, c or c++...

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#10 Post by Squashman » 15 May 2015 12:49

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.

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

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

#11 Post by Samir » 30 Oct 2015 10:12

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

Post Reply