time sync errorlevel check

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

time sync errorlevel check

#1 Post by mohdfraz » 17 May 2014 01:49

Hello,

I want that when this command runs

Code: Select all

w32tm /resync


and it should generate error message for all other quotes then this below.
The command completed successfully.


So I know it did not worked successfully and needs my attention.

Thanks

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: time sync errorlevel check

#2 Post by foxidrive » 17 May 2014 02:55

Do you want to detect the message?

Code: Select all

w32tm /resync | find /i "The command completed successfully." >nul || an error occurred&pause

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: time sync errorlevel check

#3 Post by mohdfraz » 17 May 2014 04:14

foxidrive wrote:Do you want to detect the message?


Foxidrive,
Thank you very much,,,, You are great.
It Worked like a charm 8)



I used this code for easier test,,,

Code: Select all

:loop

w32tm /resync | find /i "The command completed successfully." >nul ||Msg * Clock Not working.......

goto loop

drgt
Posts: 160
Joined: 21 Sep 2010 02:22
Location: Greece

Re: time sync errorlevel check

#4 Post by drgt » 01 May 2024 23:26

Code: Select all

@echo off
:loop
echo Attempting Time Sync...
w32tm /resync | find /i "The command completed successfully." >nul || echo Sync Not Working, Retrying...&goto loop
echo Success!!!!!
pause
exit
Looping even if successfull.
What am I doing wrong?

miskox
Posts: 627
Joined: 28 Jun 2010 03:46

Re: time sync errorlevel check

#5 Post by miskox » 02 May 2024 02:07

Try this:

Code: Select all

@echo off
:loop
echo Attempting Time Sync...
w32tm /resync | find /i "The command completed successfully." >nul || (echo Sync Not Working, Retrying...&goto loop)
echo Success!!!!!
pause
exit
You should treat the 'echo' and 'goto' as one command. You need parentheses ().

Saso

drgt
Posts: 160
Joined: 21 Sep 2010 02:22
Location: Greece

Re: time sync errorlevel check

#6 Post by drgt » 02 May 2024 03:49

Thank you Saso!

Post Reply