Sign in to follow this  
Followers 0
LoWang

autoit script is 2 hours back from local time!!

21 posts in this topic

Today I noticed very strange thing on some of our computers. The system time is 14:00 but the @hour macro in compiled script is populated with 12! WTH??

Time Zone: (GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague

I found two pcs with this problem so far, while another one where it is OK - the script shows the same time as the system clock - does not seem to have any different settings

Time Zone: (GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague

not only @hour but also _nowcalc() shows the time 2 hours backwards! Please advice. This really causes big problems for me.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Is the script run in a different user profile (like a service?) Than maybe the profile shows a different regional settings.

I had some code left from a previous problem to display the bias.

You may want to try the code to display the current settings, of course not as a fix/help but maybe just as a helping hand.

(do not look to close on the calculation line...more like a hint)

So if the line is somehow correct, you may need to start your date string not by using @hour @min and so on but from a UTC string.

#include <GuiConstantsEx.au3>
#include <Date.au3>
#include <WindowsConstants.au3>
#include <array.au3>
$tCur = _Date_Time_GetSystemTime()
$tCurStr=_Date_Time_SystemTimeToDateTimeStr($tCur)
$aTimeZone = _Date_Time_GetTimeZoneInformation ()
;~ _ArrayDisplay($aTimeZone)
 
ConsoleWrite("TimeZone:"&$aTimeZone[5]&@CRLF)
ConsoleWrite("Dayligh settings:"&$aTimeZone[0]&@CRLF)
ConsoleWrite("Current bias for this computer:"&$aTimeZone[1]&@CRLF)
ConsoleWrite("Current bias for this timezone:"&$aTimeZone[7]&@CRLF)
ConsoleWrite("@Hours is:"&@hour&@CRLF)
ConsoleWrite("UTC time:"&$tCurStr&@CRLF)
ConsoleWrite("localtime should be: UTCtime = localtime + bias pc + bias timezone"&@CRLF)
ConsoleWrite("localtime should be: "&$tCurStr&" = "&_now()&"h + "&$aTimeZone[1]&"min + "&$aTimeZone[7]&"min"&@CRLF)
Edited by Tankbuster

Share this post


Link to post
Share on other sites

Posted Image

and on the other pc where it is OK it looks like this:

Posted Image

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Make a simple script in the PC with the BUG.

Something like:

#include <Date.au3>
MsgBox(0,"",_NowCalc())

Run it on the bug PC and tell us what are the results.

@edit

Copy mistake corrected

Edited by Juvigy

Share this post


Link to post
Share on other sites

as a result of my script you see that the frist PC (wrong one)

it reports that UTC time is LOCALtime.

while the other PC2 (correct one) got a bias of 2h from UTC time.

Now this explains why @hour is wrong on PC1, but it does not explain the root cause.

Let me think about this.........maybe some where in the registry....

(btw: both run on XP/32? In user space)

Share this post


Link to post
Share on other sites

#include <Word.au3>
MsgBox(0,"",_NowCalc())
Shouldn't it be "#include <date.au3>" :graduated:

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

#Include <Date.au3>
$p=_Date_Time_GetTimeZoneInformation()
$d=_NowCalc()
msgbox(0,"time","hour:"&@HOUR&" time different from UTC:"&$p[1]&" DST bias:"&$p[7]&" _nowcalc():"&$d)

Bugged PC:

Posted Image

OK PC:

Posted Image

Both computers are Windows XP 32bit SP3

Edited by LoWang

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Something I would like to know:

Could you please check on BOTH PC the Time displayed in the BIOS?

Maybe the HW-Clock is not correct and so windows tries to display something corrected?

Edited by Tankbuster

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

the bugged computer shows 10:50 in the BIOS which is proper time for our timezone (UTC + 1 + DST)

I will now check the OK computer

the OK computer shows the same time in BIOS: 10:54 by now

Edited by LoWang

Share this post


Link to post
Share on other sites

Ah, than it's easier...it's only a matter of windows.....no, this was a joke.

If you check eg the eventlog of the PC1 does it also display wrong entries? Or are there other logs (from other apps) to have the same behavior.

I do not believe it's a matter of autoit.

BTW: if you do a "echo %TIME%" on a cmd does it show also the wrong time?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I found more pcs on our network with this problem and more pcs which are OK. This is crazy :graduated:

echo %TIME% shows time correctly

YES the other applications which make logfiles have it 2 hours back also on the bugged pc!

But windows event viewer shows correct time. Only the text log files from apps shows it 2 hours back.

Edited by LoWang

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

try this post #10 to see if it have any diffrance

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

"network" - are you also connected to a domain (controller)? If so, what's his time/timezone?

Share this post


Link to post
Share on other sites

OK PC:

C:\>cas2
_WinAPI_GetLocalTime(): 16/9/2011 12:20:50
_WinAPI_GetSystemTime(): 16/9/2011 10:20:50
@HOUR: 12

Bugged pc:

C:\>cas2
_WinAPI_GetLocalTime(): 16/9/2011 12:22:14
_WinAPI_GetSystemTime(): 16/9/2011 10:22:14
@HOUR: 10

And yes those pcs are connected to a domain controller but they have set internet time NTP server to europe.pool.ntp.org, so I am not sure if domain controller talks to it yet or not...

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

so now you know that you can use _WinAPI_GetLocalTime(): so that your time can b pulled correcty

as for @HOUR, i dont have slitest idea what can b wrong, but can you tellme one thing, your using XP sp3 on them correct? what version of XP are you using(home? pro? unstandard XP verison?)? did you instal some time addons on that mashines?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Hm that is really cool that I can just recompile all my scripts to use _WinAPI_GetLocalTime() because @hour is broken from some mysterious reason! :-\

And it is not just my scripts! Also our company software which makes logfiles is affected by this and writes timestamps 2 hours backwards.

These computers have the same image of Windows XP Professional and I did not fiddle with any time addons or whatever you mean...

I will try to reimage the one bugged pc if it changes

Edited by LoWang

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

reimage of the computer fixed the problem. I am now looking how many more computers with this problem I will find on our network...

Interestingly I found only 5 more pcs with this problem out of about 700 total :-]

Edited by LoWang

Share this post


Link to post
Share on other sites

Very strange issue - did you try changing the zone ? I remember there was some issue with the Daylight saving check on XP. MS issued a fix that may be the issue here.

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

I did not fiddle with any time addons or whatever you mean...

I will try to reimage the one bugged pc if it changes

i mean something like timezone addon

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=25166

or something similar that can messup something

newer the less i think that you shud recompile with _WinAPI_GetLocalTime only 2 b shure that something like that if it happend in the future will not influence your scripts any more.

and + you can add something like this so that you can get neare the problem if it ever happen

$time = _WinAPI_GetLocalTime()

if $time[X] <> @HOUR then MsgBox(0,'Your time probably isnt displaying correctly','Pls report this msg to your administrator')

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

sh*t It's screwed up again. That pc I fixed by reinstallation started to do it again this morning! I give up and will recompile my scripts with this crazy Win API :-\ I hope it will not be taking too much CPU if processed often.

But this is no solution for the other software running on such a machine which is confused too by this...Like symantec antivirus for example.

Edited by LoWang

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0