Jump to content
Sign in to follow this  
water

Ending a script takes forever on Windows 7

Recommended Posts

water

Hi everybody,

I notice a strange behaviour that only occurres when I start the script from SciTe using F5. It takes the script about 55 seconds to end after writing "Exit".

The compiled script ends immediately.

This only happens on Windows 7. The same script on Windows XP just runs fine.

#AutoIt3Wrapper_UseX64=n
#include <AD.au3>
$R = _AD_Open()
$R = _AD_Close()
ConsoleWrite("Exit" & @CRLF)
Exit

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "H:\tools\AutoIt3\AD\AD_Test2.au3" /autoit3dir "C:\Program Files (x86)\AutoIt3" /UserParams   
+>19:23:14 Starting AutoIt3Wrapper v.2.0.1.22   Environment(Language:0407 Keyboard:00000407 OS:WIN_7/ CPU:X64 OS:X64)
>Running AU3Check (1.54.19.0) from:C:\Program Files (x86)\AutoIt3
+>19:23:15 AU3Check ended.rc:0
>Running:(3.3.6.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "H:\tools\AutoIt3\AD\AD_Test2.au3"    
Exit
+>19:24:08 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 54.643

It doesn't matter if I compile it for X64 or X86.

I checked that every object I create in _AD_Open is reset in _AD_Close. I suppose it's some kind of cleanup or a timeout that takes the time.

Does anyone have an idea what happens here?

Thanks in advance!

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
Painkiller

Hi everybody,

I notice a strange behaviour that only occurres when I start the script from SciTe using F5. It takes the script about 55 seconds to end after writing "Exit".

The compiled script ends immediately.

This only happens on Windows 7. The same script on Windows XP just runs fine.

#AutoIt3Wrapper_UseX64=n
#include <AD.au3>
$R = _AD_Open()
$R = _AD_Close()
ConsoleWrite("Exit" & @CRLF)
Exit

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "H:\tools\AutoIt3\AD\AD_Test2.au3" /autoit3dir "C:\Program Files (x86)\AutoIt3" /UserParams   
+>19:23:14 Starting AutoIt3Wrapper v.2.0.1.22   Environment(Language:0407 Keyboard:00000407 OS:WIN_7/ CPU:X64 OS:X64)
>Running AU3Check (1.54.19.0) from:C:\Program Files (x86)\AutoIt3
+>19:23:15 AU3Check ended.rc:0
>Running:(3.3.6.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "H:\tools\AutoIt3\AD\AD_Test2.au3"    
Exit
+>19:24:08 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 54.643

It doesn't matter if I compile it for X64 or X86.

I checked that every object I create in _AD_Open is reset in _AD_Close. I suppose it's some kind of cleanup or a timeout that takes the time.

Does anyone have an idea what happens here?

Thanks in advance!

I am not sure if this will be an exact solution for you, but when i want to exit a script i do:

exit(1)

I use that instead of just "Exit" and my scripts close on Win7 Home Premium 64 Bit right away. Otherwise the only other thing i can think of is if another program or .dll is executed by your program is takin time to fully close and Autoit is (for some reason) waiting for that program or .dll to close completely.

Share this post


Link to post
Share on other sites
water

Hi everybody,

I was able to strip down the example and create a reproducer script. The problem is caused by line 5 (ObjGet("LDAP://RootDSE")).

If I remove this line the script runs in 0.3 seconds. Otherwise it takes 55 seconds.

It's a problem of compiled scripts too. I ran some old compiled scripts and they stay idle for about 55 seconds before the process is ended.

$TI = TimerInit()
Global $oAD_Connection = ObjCreate("ADODB.Connection")
$oAD_Connection.ConnectionString = "Provider=ADsDSOObject"
$oAD_Connection.Open()
Global $oAD_RootDSE = ObjGet("LDAP://RootDSE")
ConsoleWrite("Runtime: " & TimerDiff($TI) & @CRLF)
Exit

As this runs fine on Windows XP it might be a problem with my Windows 7 setup (we are just migrating to W7 and my W7 machine is a test machine)

or with the AD?

Any ideas are greatly appreciated!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
NiVZ

Hi everybody,

I was able to strip down the example and create a reproducer script. The problem is caused by line 5 (ObjGet("LDAP://RootDSE")).

If I remove this line the script runs in 0.3 seconds. Otherwise it takes 55 seconds.

It's a problem of compiled scripts too. I ran some old compiled scripts and they stay idle for about 55 seconds before the process is ended.

$TI = TimerInit()
Global $oAD_Connection = ObjCreate("ADODB.Connection")
$oAD_Connection.ConnectionString = "Provider=ADsDSOObject"
$oAD_Connection.Open()
Global $oAD_RootDSE = ObjGet("LDAP://RootDSE")
ConsoleWrite("Runtime: " & TimerDiff($TI) & @CRLF)
Exit

As this runs fine on Windows XP it might be a problem with my Windows 7 setup (we are just migrating to W7 and my W7 machine is a test machine)

or with the AD?

Any ideas are greatly appreciated!

I've noticed this behaviour too. Interestingly, I found that it works OK if the script is compiled and then the .exe is run. It only seems to take ages when running in the editor.

NiVZ

Share this post


Link to post
Share on other sites
water

I've noticed this behaviour too. Interestingly, I found that it works OK if the script is compiled and then the .exe is run. It only seems to take ages when running in the editor.

NiVZ

Hi NiVZ,

that sounds interesting!

Could you please start the taskmanager, run your compild script and verify if the process closes immediately or if it stays idle for about 55 seconds?

On my Windows7 machine it doesn't make any difference. Both interpreted and compiled scripts take 55 seconds for the process to end.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
SmOke_N

Win7 x64

+>06:19:52 AU3Check ended.rc:0

>Running:(3.3.6.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\AU3\_Misc.au3"

Runtime: 6813.2926206807

+>06:20:00 AutoIT3.exe ended.rc:0

Edit:

Relevant? Google search link that kept screwing up during pasting

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
water

@SmOke_N

I checked the google page. But - as far as I understand it - it doesn't help in my case because my script doesn't use a Driver.

@All

This can't be a connection timeout problem (I think). I added

$oAD_Connection.ConnectionTimeout = 10

but the script stills need 55 seconds to exit.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
SmOke_N

@SmOke_N

I checked the google page. But - as far as I understand it - it doesn't help in my case because my script doesn't use a Driver.

@All

This can't be a connection timeout problem (I think). I added

$oAD_Connection.ConnectionTimeout = 10

but the script stills need 55 seconds to exit.

Well, mine finished in less than 7 seconds on Win7. So... that would tell you what?

Edit:

I'm probably not the best to test this:

$TI = TimerInit()

Global $oAD_RootDSE = ObjGet("LDAP://RootDSE")
If Not IsObj($oAD_RootDSE) Then
    ConsoleWrite("err... rootdse" & @CRLF)
    Exit
EndIf


Global $oAD_Connection = ObjCreate("ADODB.Connection")
If Not IsObj($oAD_Connection) Then
    ConsoleWrite("err... connection" & @CRLF)
    Exit
EndIf
$oAD_Connection.ConnectionString = "Provider=ADsDSOObject"
;~ $oAD_Connection.Open()
ConsoleWrite("Runtime: " & TimerDiff($TI) & @CRLF)
Exit
Getting the object LDAP://RootDSE is what took all the time for me, and that was failing anyway.

Also, when I googled, seemed your statements were backwards from theirs. Anyway, switching them around didn't help either.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
water

Well, what do we have so far?

  • One user (NiVZ) who notices the same problem as I have
  • One user (you) that doesn't seem to have the problem
I wonder why it takes 7 seconds for your script to end. Could you pleae remove the line

Global $oAD_RootDSE = ObjGet("LDAP://RootDSE")
and see how fast it runs now? Mine takes 1.4 seconds.

As the ConsoleWrite is done without delay after the ObjGet I just can guess that it's some kind of cleanup either on the client or AD server side.

I goggled high and low but can't find anything that seems to be close.

Thanks for taking the time to help me with my poblem.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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
SmOke_N

As I stated in my edit, my same issue is what you suspect. It took 15 milliseconds for me.

Now you do know that TimerDiff() returns the results in milliseconds right?

To get seconds, your final ConsoleWrite should be:

ConsoleWrite("Runtime: " & TimerDiff($TI) / 1000 & @CRLF)

I only mention this because no way should it have taken 1.5 seconds to connect to the ADODB .


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
water

I only mention this because no way should it have taken 1.5 seconds to connect to the ADODB .

You are right! I posted the wrong number. It's been the total time as reported at the end of the script like

>Exit code: 0   Time: 1.225

The TimerDiff shows about 40 milliseconds.

As I'm now running out of ideas I will leave for weekend. Maybe I have some fresh ideas on monday ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - 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

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  

×