Page 1 of 1
open file at a specific time
Posted: 15 Aug 2020 09:44
by cpampas
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
Re: open file at a specific time
Posted: 15 Aug 2020 15:34
by aGerman
You may use the TIMEOUT command which suspends the batch execution for the specified number of seconds.
Steffen
Re: open file at a specific time
Posted: 16 Aug 2020 06:49
by cpampas
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?
Re: open file at a specific time
Posted: 17 Aug 2020 05:12
by penpen
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