Jump to content

WIN 10 AutoIT script freezing when computer is locked


Recommended Posts

My company is moving from WIN7 to WIN10, I have had a script that runs in the middle of the night, when the computer is locked, to open an Excel spreadsheet, read a few cells, and generate an email.  This has worked fine under WIN7, when I try to run under WIN10 it freezes when it gets to a line to handle an array.  When I run without the computer locked the script runs as expected.  After doing a lot of investigating, it looks like the following line reads a "0" from the Excel file instead of a text string, only when the computer is locked.

Any ideas?

$Driver1 = _Excel_RangeRead($oWorkbook, "Template", "H12")

This is how I am opening the Excel file:

Local $oExcel = _Excel_Open(False)
Sleep(10000)
$oWorkbook = _Excel_BookOpen($oExcel, $sFilePath, True, False)

Link to comment
Share on other sites

How is this script getting launched each night?  Is it being launched by the Task Scheduler?  If so, I had a similar issue and it was very easy to resolve.

The reason you are getting 0 back from the RangeRead is most likely because it failed.  If you look at the function, you can see that when the function fails, it sets @error and returns 0.  Given the snippet that you posted, you don't even know if the Open or BookOpen functions were successful.  I suspect that they were not.

On a side note, you should add error checking with logging to your script(s).  It would help you in being able to better trouble shoot issues.

Edited by TheXman
Link to comment
Share on other sites

Thanks for the feedback.

Using Task Scheduler to call program under my network credentials.  Added in the error checking from examples in help for those two functions.  The _Excel_Read is where it is failing, but only when locked, with error code saying file not found.  Changed the excel_read function to remote the HTTP test.  Played with the visible and not visible settings and even trusted locations in Excel.  Tried with XLSM file on network and on local hard drive with no success. 

Ended up just writing list of names to text file on network and that processes just fine.

 

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

×
×
  • Create New...