Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
dwngrt
- Posts: 26
- Joined: 07 Oct 2013 05:14
- Location: The Netherlands
#1
Post
by dwngrt » 14 Oct 2013 08:40
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!
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 14 Oct 2013 10:54
What about
Code: Select all
if "%time:~0,5%"=="12:00" msg * Lunch time
Regards
aGerman
-
dwngrt
- Posts: 26
- Joined: 07 Oct 2013 05:14
- Location: The Netherlands
#3
Post
by dwngrt » 21 Oct 2013 01:06
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 .-.
-
Batch Artist
- Posts: 22
- Joined: 18 Oct 2013 05:28
#4
Post
by Batch Artist » 21 Oct 2013 01:14
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 "*"??
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#5
Post
by foxidrive » 21 Oct 2013 01:15
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.
-
dwngrt
- Posts: 26
- Joined: 07 Oct 2013 05:14
- Location: The Netherlands
#6
Post
by dwngrt » 21 Oct 2013 01:45
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.
-
jeb
- Expert
- Posts: 1055
- Joined: 30 Aug 2007 08:05
- Location: Germany, Bochum
#7
Post
by jeb » 21 Oct 2013 01:55
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.
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#8
Post
by ShadowThief » 21 Oct 2013 02:23
if it's am, it will probably be " 9:05" (note the space before the 9)
-
dwngrt
- Posts: 26
- Joined: 07 Oct 2013 05:14
- Location: The Netherlands
#9
Post
by dwngrt » 21 Oct 2013 05:15
nopes we are using the europe time (24H)
-
dwngrt
- Posts: 26
- Joined: 07 Oct 2013 05:14
- Location: The Netherlands
#10
Post
by dwngrt » 21 Oct 2013 05:16
WOOHOO i got it to work
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
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#11
Post
by foxidrive » 21 Oct 2013 06:32
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.
-
Batch Artist
- Posts: 22
- Joined: 18 Oct 2013 05:28
#12
Post
by Batch Artist » 23 Oct 2013 03:52
dwngrt wrote:WOOHOO i got it to work
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!