Jump to content

autoit script is 2 hours back from local time!!


LoWang
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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)

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

#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
Link to comment
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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

 
Link to comment
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...

Link to comment
Share on other sites

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.

 
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

 
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...