Page 1 of 1

"Just in time"

Posted: 14 Oct 2013 08:40
by dwngrt
So during my finetuning i thought it would be practical to add a function for auto pop-ups, something like this:

Code: Select all

@echo off && cls && Setlocal EnableDelayedExpansion
:start
if %time%=='12:00:*,*' msg * Lunch time
ping localhost -n 2 >NUL && goto start


any ideas on how to fix this? ^^
thanks in advanced!

Re: "Just in time"

Posted: 14 Oct 2013 10:54
by aGerman
What about

Code: Select all

if "%time:~0,5%"=="12:00" msg * Lunch time

Regards
aGerman

Re: "Just in time"

Posted: 21 Oct 2013 01:06
by dwngrt
Thank you for you're awnser but sadly it doesn't work for me, here is my test script:

Code: Select all

@echo off
Setlocal EnableDelayedExpansion
:1
cls
echo %time%
echo msg will be send @ 09:05
if "%time:~0,5%"=="9:05" msg * its 5 passed 9
ping localhost -n 2 >NUL
goto 1

maybe i did something wrong, but i think not .-.

Re: "Just in time"

Posted: 21 Oct 2013 01:14
by Batch Artist
dwngrt wrote:So during my finetuning i thought it would be practical to add a function for auto pop-ups, something like this:

Code: Select all

@echo off && cls && Setlocal EnableDelayedExpansion
:start
if %time%=='12:00:*,*' msg * Lunch time
ping localhost -n 2 >NUL && goto start


any ideas on how to fix this? ^^
thanks in advanced!


Are you planning for the pop-ups to occur on your CMD, or a messenger box?
If a Messenger Box, you'll need to do so using .VBS format, not .BAT.
May I ask though, what is with all the "*"??

Re: "Just in time"

Posted: 21 Oct 2013 01:15
by foxidrive
dwngrt wrote:

Code: Select all

if "%time:~0,5%"=="9:05" msg * its 5 passed 9




Your time format could be different from another PC, but you're checking the first 5 characters and comparing it with 4 characters, which will never work.

Re: "Just in time"

Posted: 21 Oct 2013 01:45
by dwngrt
I tested various ways, 09:05 doesn't work, same with 9:05.
@Batch Artist:
Both way's are fine, but a pop-up would be best in this situation.
But i think it should be possible because the IF fucntion works (as it should on every windows OS) and since these are XP system's we are working on here the MSG function also works, the only thing i need to do is to get the time check thinggy working.

Re: "Just in time"

Posted: 21 Oct 2013 01:55
by jeb
dwngrt wrote:I tested various ways, 09:05 doesn't work, same with 9:05.

It could be a better idea to see what the output is on your system.

Code: Select all

echo "%time%"

Re: "Just in time"

Posted: 21 Oct 2013 02:23
by ShadowThief
if it's am, it will probably be " 9:05" (note the space before the 9)

Re: "Just in time"

Posted: 21 Oct 2013 05:15
by dwngrt
nopes we are using the europe time (24H)

Re: "Just in time"

Posted: 21 Oct 2013 05:16
by dwngrt
WOOHOO i got it to work :D
thank you all for you're help!
here is the working code :3

Code: Select all

@echo off
Setlocal EnableDelayedExpansion
:1
cls
echo %time%
echo msg will be send @ 09:05
if "%time:~0,5%"=="13:16" msg * pauze pik
ping localhost -n 2 >NUL
goto 1

Re: "Just in time"

Posted: 21 Oct 2013 06:32
by foxidrive
ShadowThief wrote:if it's am, it will probably be " 9:05" (note the space before the 9)


AIR this is correct, even in 24 hour time.

Re: "Just in time"

Posted: 23 Oct 2013 03:52
by Batch Artist
dwngrt wrote:WOOHOO i got it to work :D
thank you all for you're help!
here is the working code :3

Code: Select all

@echo off
Setlocal EnableDelayedExpansion
:1
cls
echo %time%
echo msg will be send @ 09:05
if "%time:~0,5%"=="13:16" msg * pauze pik
ping localhost -n 2 >NUL
goto 1


Congrats are in order!