Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
sklub
- Posts: 9
- Joined: 13 Jan 2017 12:56
#1
Post
by sklub » 15 Jan 2017 15:55
Code: Select all
@echo off
:AT
Rem Enter time
set AT=00:00
Rem Enter command
set DO=start cmd
:ClockMain
set time=%time%
if %time:~1,1%==: goto :timeA
if %time:~2,1%==: goto :timeB
goto :ClockMain
:timeA
set A=0
set B=%time:~0,1%
set C=%time:~2,1%
set D=%time:~3,1%
goto :DoAt
:timeB
set A=%time:~0,1%
set B=%time:~1,1%
set C=%time:~3,1%
set D=%time:~4,1%
goto :DoAt
:DoAt
set Mytime=%A%%B%:%C%%D%
if %Mytime%==%AT% %DO%
echo %Mytime% %AT%
timeout /t 1 > null.txt
del null.txt
cls
Goto :ClockMain
Last edited by
Squashman on 15 Jan 2017 21:06, edited 1 time in total.
Reason: MOD EDIT: Please use code tags.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 15 Jan 2017 21:21
Code: Select all
@echo off
:AT
Rem Enter time
set AT=00:00
Rem Enter command
set DO=start cmd
:ClockMain
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set Mytime=%dt:~8,2%:%dt:~10,2%
if %Mytime%==%AT% %DO%
echo %Mytime% %AT%
timeout /t 1 >nul
cls
Goto ClockMain