open file at a specific time

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
cpampas
Posts: 2
Joined: 15 Aug 2020 09:37

open file at a specific time

#1 Post by cpampas » 15 Aug 2020 09:44

Hi,
I am a total newbie with programming batch files, so I wonder if it is posible to have a batch file that opens a file in my computer at a specific time, like

c:\infoBet.accdb ' I would like this file to be open 2 minutes after the batch is executed
I appreciatte your help

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: open file at a specific time

#2 Post by aGerman » 15 Aug 2020 15:34

You may use the TIMEOUT command which suspends the batch execution for the specified number of seconds.

Steffen

cpampas
Posts: 2
Joined: 15 Aug 2020 09:37

Re: open file at a specific time

#3 Post by cpampas » 16 Aug 2020 06:49

That works great, thank you
Since it is related to the same question, can I apart from the timeout set another parameter, that the timeout should only start counting if the is NOT between 02 AM and 5 AM?

penpen
Expert
Posts: 1988
Joined: 23 Jun 2013 06:15
Location: Germany

Re: open file at a specific time

#4 Post by penpen » 17 Aug 2020 05:12

You could extract time information using for- and wmic-command and then check if you are not within 2 and 5 am

Code: Select all

@echo off
setlocal enableExtensions enableDelayedExpansion
set "stamp="
for /f "skip=1 delims=.," %%a in ('wmic os get localDateTime') do if not defined stamp set "stamp=%%~a"
set /a "stamp=1%stamp:~8%-1000000"
if %stamp% lss 20000 rem: your timeout cmd
if %stamp% gtr 50000 rem: your timeout cmd
:: rest of your code
Sidenote: You could instead use your environment variable "time" for that purpose, but as that is localized i don't know the exact format on your system.

penpen

Post Reply