Sign in to follow this  
Followers 0
Huysmans

Problem Running Autoit Using Scheduled_tasks

10 posts in this topic

I'm lost! Here's a little mind-puzzle for you experts.

I am using AutoIt to administer a navision attain environment. One of the nice things AutoIt can do is automate standard report generation. I created a script which does the trick nicely. Both in script form and as executable.

When I try to schedule the script using scheduled tasks; this will result in a hanging Navision session. I have been looking at the process information and all I can see is:

start autoit proc (or my compiled version)

start navision attain session

stop autoit proc

leaving the navision attain session hanging around (which can easily be terminated using the end_process_tree from windows taskmanager).

I'm running on a W2K (version 5.0, build 2195, service pack 3) and am using AutoIt v.3.0.101.0.

I would appreciate any pointer into a new direction. As said; I'm lost and slowly growing bold (pulling out my hair from agony :ph34r:).

Share this post


Link to post
Share on other sites



have you tryed closing the thing from autoit once its done doing whatever?

Share this post


Link to post
Share on other sites

You shouldn't ever need a GUI on something ment to launch as a system service. The whole point of a service is to run transparent to any user that logs on.

If you really want a GUI, you should start the main service instance to do all the "work," even when there is no user logged in. You should also put a "child" scirpt in the "All Users" startup directory (or registry) so that the GUI client can start up whenever a user is logged in. Then, if you want a GUI message or interface to the service, the GUI could interact with the main instance.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

I currently run about 4 daily autoit scripts with task squeduler.

One thing to be sure is that when running tasks, you need to make sure your windows are viewable if you are using commands that use them.

Example:

If your script uses winwaitactive, you need to be able to see that window, as in Logged on.

Use of Control functions when useing squeduled tasks is highly recomended.

ScreenSavers can also be a problem with certain scripts.

I save about 4 hours of work by having autoit do all my downloads, backups, and maintainance chores while I sleep. And by downloads I don't mean porn or personal stuff, but work website and SQL maintainance.


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Thanks guys for thinking! Still puzzling... Let me recap:

Navision Attain is a system service (one service combining database engine and application server). Navision has a crappy build-in scheduling service.

I created my own system maintenance batch (generic for all servers in the parc) which will take care of various service shutdown/startup, backup to disk/tape, system integrity checks etc. This batch has been written using Perl and works like a charm.

During the batch I also want to perform some Navision maintenance tasks. As Navision is a GUI based environment, the only way to achieve this is by emulating the user-interaction. Thank God I found AutoIt. Seems the perfect tool to get things working. And yes, I have now scripts to automate several time-consuming tasks. Each of these scripts works nicely, as long as execution is initiated by hand.

But imagine; logistics would like to start each day with bunch of picking-orders already printed out. And yes, this can be automated using AutoIt (script is working). However I don't feel like getting out at 0600 each morning just to kick off a script. I would like to have it scheduled as a task (either using scheduled-tasks or as entity in my batch processing). And this is where the rumbling starts....

Investigation shows:

* auto-it will be started

* navision session will be started

* using database monitor I can detect the existance of a client session

* unfortunately, it seems the client is unable to pass the first dialog (log-on)

In contrast with my previous posting, I have to conclude that both the navision session and the auto-it session will not terminate. And just to rule out the obvious; yes, the user-id used for scheduled task is identical to the one using command-line execution.

I'm getting the feeling that it just isn't possible to schedule automated user-interaction... :( If the only way to get this done is to display the GUI on the console window, thats fine. Question is how do I achieve this? Anyone, any idea/suggestion? :ph34r:

Share this post


Link to post
Share on other sites

did you enable desktop interaction on the scheduled task? that seems to be a common fix.


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

did you enable desktop interaction on the scheduled task?  that seems to be a common fix.

<{POST_SNAPBACK}>

How this can be done?

Share this post


Link to post
Share on other sites

How this can be done?

<{POST_SNAPBACK}>

I't can as far as I can tell for any less than 1 minute, and even then still freezes. As discussed in other posts, VNC Server "might" work - as I'm still testing - Terminal Services does not.

Share this post


Link to post
Share on other sites

I't can as far as I can tell for any less than 1 minute, and even then still freezes.  As discussed in other posts, VNC Server "might" work - as I'm still testing - Terminal Services does not.

<{POST_SNAPBACK}>

ooops - that was - "It Can't" - sorry...

PS (talk about typing ahead :ph34r:

Share this post


Link to post
Share on other sites

Yes! Finally got it working.

Bottom line:

* do not use "send"; use "controlsend" instead

* do not use "msgbox" without the timeout argument

* address windows using their handle whenever possible

* test when calling from commandline / explorer

* take over console using VNC, DameWare, or alike and test using "scheduled tasks" while leaving console session open

Other things I changed included reducing the speed:

AutoItSetOption("WinWaitDelay", 500) ; default 250

AutoItSetOption("SendKeyDelay", 10) ; default 5

AutoItSetOption("SendKeyDownDelay", 2) ; default 1

Finally; realize there is a significant difference between tools like terminalserver and tools like VNC.

Thanks to all you guys who pointed me in the right direction!

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