timed batch file execution
Moderator: DosItHelp
timed batch file execution
hi
I need a batch script to start at a particular time everyday (say 9AM) and execute notepad.exe.
iam not interested in using windows task scheduler or any other utility.
any help ??
thanx in advance for sparing me your valuable time
I need a batch script to start at a particular time everyday (say 9AM) and execute notepad.exe.
iam not interested in using windows task scheduler or any other utility.
any help ??
thanx in advance for sparing me your valuable time
Re: timed batch file execution
Then you are out of luck. SCHTASKS would be for sure the preferred command but it does nothing else but creating a scheduled task.iam not interested in using windows task scheduler
Steffen
Re: timed batch file execution
You need some type of scheduling daemon or service. Not sure how you think this can be done otherwise.
Re: timed batch file execution
You could do something like this:
Saso
Code: Select all
:start
if current_time more than 09:00 then notepad.exe
wait 1 minute (or wait 24 hours)
goto start
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
-
- Expert
- Posts: 961
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
Re: timed batch file execution
this?miskox wrote: ↑09 Dec 2017 14:01You could do something like this:
SasoCode: Select all
:start if current_time more than 09:00 then notepad.exe wait 1 minute (or wait 24 hours) goto start
Code: Select all
@echo off
:label
ping 127.0.0.1 -n 2 >nul
if %time:~0,2% equ 9 if %time:~3,2% equ 0 (
start notepad.exe
ping 127.0.0.1 -n 86398 >nul
)
goto label
-
- Posts: 240
- Joined: 04 Mar 2014 11:14
- Location: germany
Re: timed batch file execution
This will only use robocopy to pause this time
Phil
Code: Select all
@echo off
echo Start this batch at %time%
rem Pausiere Programmablauf wenn END Uhr bis begin Uhr
rem Mindestens zwei Minuten Überbrücken /RH:Ende-Beginn
rem Eine Minute vom Beginn abziehen
setlocal
:: /RH:%Ende%-%Beginn%
:: set Beginn is End Time for start - set this Time one minute before -means start for wait ; minute -1
:: set Ende
:: PauseEnd -before this time robocopy not start ; No Copy -script ends
:: -between pause and robocopy start ; Copy -
:: -when arrived pause END then script starts ; success
:: PauseBegin -after robocopy not start ; No Copy
rem Pause
set begin=0600
set end=0900
set "RC=%temp%\RCtmp.log"
type nul >"%RC%"
robocopy . . " Zeitfenster ." /RH:%End%-%Begin% /L /W:1 /R:1 /nFL /nDL /njH /njS /tee /Log:"%RC%" |(
for /f "tokens=1*" %%a in ('find "..." ^^^<"%RC%"') do @(
echo Zeit fuer eine Pause %time%
>&3 echo Zeit fuer eine Pause %time%
echo Programm wird %%b
>&3 echo Programm wird %%b
) >> D:\Log.txt
) && (
echo this program will be continued
rem start programm
goto :continue
) || (
echo abort batch from %end:~,2%:%end:~-2% to %begin:~,2%:%begin:~-2% ,Time:%time%
rem goto :something
)
del "%RC%"
pause
exit /b
:continue
del "%RC%"
echo start program at %time%
pause
rem ...
Re: timed batch file execution
A little late to the party, but I use this in several batches. It doesn't require anything external except the ping command. It starts the batch at 1am.
Code: Select all
:START
PING -n 60 127.0.0.1 > NUL
SET CURTIME=%TIME:~0,-6%
IF NOT "%CURTIME%"==" 1:00" GOTO START
Re: timed batch file execution
I think you are all missing the intended request. The user said they wanted a batch file to start a particular time of the day. They are not asking to pause execution of a batch file until a specified time of the day.
Re: timed batch file execution
Hmmm...but if the main loop of the batch file won't start until the specified time, isn't that about the same thing?
Re: timed batch file execution
Without scheduled tasks the answers given may be the only option, but I agree with Squashman, they aren't what was asked for.
What was asked for was a batch file which runs at a specific time, not a constantly running batch file.
What was asked for was a batch file which runs at a specific time, not a constantly running batch file.
Re: timed batch file execution
I disagree, WSH.sleep is good cpu conserving, ping not so much, ping also needs ethernet support or errors out.ShadowThief wrote: ↑09 Dec 2017 14:02Maybe he's expecting to be able to use an infinite loop and a timeout command. (Don't do that by the way; you'll blow up your processor.)
Code: Select all
<!-- : Enable embedded WSF comment
@echo off
cScript.EXE //noLogo "me myself &I.WSF" //job:JScript sleep_
goto :skip
:: --------------------------------------------------------------------------------------------------------------------------
:: WSF script ( function, arguments,"" )
:: --------------------------------------------------------------------------------------------------------------------------
:: last updated : 2015^06^03
:: support : naDelayed
:: languages : N/A
::
:: ( disable embedded WSF comment -->
<package>
<job id="JScript"><script language="JScript">
if ( WScript.Arguments.length > 0 ) {
if ( WScript.Arguments(0) == "sleep_" ) {
var $time;
//
if ( WScript.Arguments.length > 1 ) {
$time = WScript.Arguments(1);
} else $time = 1;
$time = $time +'000';
//
WSH.sleep( $time );
};
};
</script></job>
<job id="VBScript"><script language="VBScript">
If WScript.Arguments.length > 0 Then
rem (
a vbscript function doing something...
rem )
End If
</script></job>
</package>
<!-- : Enable embedded WSF comment :: )
:: --------------------------------------------------------------------------------------------------------------------------
:skip () disable embedded WSF comment, must be last line in batch ! -->