jdunlop

AutoIT script running fine in foreground but failing as scheduled job

6 posts in this topic

#1 ·  Posted

I inherited an AutoIT script that has been running ok for years on an Windows XP pc.

It logs onto a SAP server and extracts data to a local file on the C: drive.

Recently I moved the script to a Windows 8.1 PC and found that although I can run the script manually and it works fine,

when it is added to a scheduler and run as a scheduled job, the code stops working and the program hangs.

I have tried everything I can think of including changing the "Send" commands to ControlSend commands.

I cannot figure out why the same code would work fine every time when run manually but when scheduled, it fails.

Anyone have any ideas about this?

Share this post


Link to post
Share on other sites



#2 ·  Posted

Welcome to AutoIt and the forum!

As a scheduled job your script is being run with different credentials. So the problem you face might be caused by missing simple permissions.
Add as much error checking to your script and log all results to a log file.


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

#3 ·  Posted

Thanks for your reply, water.  Yes, I have done just that. I write to a logfile after every command and although I have now managed to get the script to complete, it doesn't execute correctly. It extracts data from a SAP database and creates a file on the C: drive but the file never gets created for some reason when run as a scheduled job. I understand that the job is run with different credentials but I can't see where Windows 8.1 would have the difference.

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Hard to tell without having seen your script.


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

#5 ·  Posted

Solved it.  Thanks, water, you put me on the right track.  It turned out that the scheduler was running the job as a System task rather than a User task which was why the credentials were different.  I changed it to a User task and it works ok.  Thanks for your help.  :)

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

:) 


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

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