Sign in to follow this  
Followers 0
wxfield

Using 'AT' daemon to schedule an AutoIT exe

8 posts in this topic

Hello, I read the FAQs and have not come to any useful conclusions about this problem, so here it is...

We have created a fairly simple AutoIT script that (when executed) will start an InstallShield Installer and handle it.

The process works perfectly if you were to execute the AutoIT exe manually. The problem comes when we try to schedule it.

If we use the windows 'AT' command to schedule it, the job executes and appears in the Tasklist. However the two processes (the AutoIT exe and the InstallShield exe) appear to just 'hang' in the process list. We logged each step in the AutoIT exe and we know that the AutoIT script is waiting indefinitely for the first window on the InstallShield app to appear.

It might be interesting to note that we also tried using psexec to accomplish the same thing (psexec replacing the 'at' scheduler), and we got exactly the same results. Coming from a *nix background I have a theory that maybe I'm not running in a session that allows AutoIT to perform normally. All these processes are run as Administrator incidentally.

Share this post


Link to post
Share on other sites



If you're scripting a GUI you'll want to make sure you run the task as interactive (/INTERACTIVE i think...) or it won't be able to access the GUI.

Share this post


Link to post
Share on other sites

If you're scripting a GUI you'll want to make sure you run the task as interactive (/INTERACTIVE i think...) or it won't be able to access the GUI.

Tried that..same result. I wonder if (since I'm executing the AutoIT exe as /INTERACTIVE) the AutoIT exe must get also instantiate the InstallShield app similarly?

Is that even possible?

Share this post


Link to post
Share on other sites

Tried that..same result. I wonder if (since I'm executing the AutoIT exe as /INTERACTIVE) the AutoIT exe must get also instantiate the InstallShield app similarly?

Is that even possible?

I would recommend the following:

1. Dump AT.exe. Use SchTasks.exe to create and manage tasks, not the depricated AT.exe command.

2. If you ever open an AT job in Task Scheduler, it is converted automatically to a SchTasks job and can no longer be managed by AT.exe. In the process, some options, like "/interactive" may get dropped. SchTasks uses the same job objects Task Scheduler does, so it avoids the issue.

3. Don't run the .exe file directly. Make your command line for the task something like 'START "C:\Full\Path\SomeName.cmd"', and have that batch file run your .exe. This causes a shell environment with system environment variables and drive mappings to be created for the job.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I would recommend the following:

1. Dump AT.exe. Use SchTasks.exe to create and manage tasks, not the depricated AT.exe command.

2. If you ever open an AT job in Task Scheduler, it is converted automatically to a SchTasks job and can no longer be managed by AT.exe. In the process, some options, like "/interactive" may get dropped. SchTasks uses the same job objects Task Scheduler does, so it avoids the issue.

3. Don't run the .exe file directly. Make your command line for the task something like 'START "C:\Full\Path\SomeName.cmd"', and have that batch file run your .exe. This causes a shell environment with system environment variables and drive mappings to be created for the job.

:)

I made the batch file. I tested it as Administrator and it runs as expected in the logged-in environment.

However when I schedule it, it fails to run. With 'at' I saw it appear in the tasklist, but with this facility, I get nada.

schtasks /Create /IT /SC ONCE /TN uninstall /TR "C:\sb\testing\uninstall.bat" /ST 10:53

SUCCESS: The scheduled task "uninstall" has successfully been created.

C:\sb\testing\automation\perl\tests\iSCSI\HITKit\HIT Installer>schtasks /Query

TaskName Next Run Time Status

==================================== ======================== ===============

uninstall 10:53:00 AM, 5/29/2009

And at 10:54..

C:\sb\testing\automation\perl\tests\iSCSI\HITKit\HIT Installer>schtasks /Query

TaskName Next Run Time Status

==================================== ======================== ===============

uninstall Never Could not start

Share this post


Link to post
Share on other sites

I made the batch file. I tested it as Administrator and it runs as expected in the logged-in environment.

However when I schedule it, it fails to run. With 'at' I saw it appear in the tasklist, but with this facility, I get nada.

schtasks /Create /IT /SC ONCE /TN uninstall /TR "C:\sb\testing\uninstall.bat" /ST 10:53

SUCCESS: The scheduled task "uninstall" has successfully been created.

C:\sb\testing\automation\perl\tests\iSCSI\HITKit\HIT Installer>schtasks /Query

TaskName Next Run Time Status

==================================== ======================== ===============

uninstall 10:53:00 AM, 5/29/2009

And at 10:54..

C:\sb\testing\automation\perl\tests\iSCSI\HITKit\HIT Installer>schtasks /Query

TaskName Next Run Time Status

==================================== ======================== ===============

uninstall Never Could not start

You have to specify the "/RU UserName" and "/RP PassWord" parameters to match the logged in user for "/IT" to work.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You have to specify the "/RU UserName" and "/RP PassWord" parameters to match the logged in user for "/IT" to work.

:)

schtasks prompted me for usr/pass before queueing...so i figured it was ok to omit..but i tried /RU /RP to see what would happen anyway..

C:\>schtasks /Create /IT /SC ONCE /TN uninstall /TR "C:\sb\testing\uninstall.bat" /ST 11:22 /RU Administrator /RP automation /Z

SUCCESS: The scheduled task "uninstall" has successfully been created.

C:\>time

The current time is: 11:21:16.01

Enter the new time:

C:\>schtasks /Query

TaskName Next Run Time Status

==================================== ======================== ===============

uninstall 11:22:00 AM, 5/29/2009

C:\>time

The current time is: 11:22:16.34

Enter the new time:

C:\>schtasks /Query

TaskName Next Run Time Status

==================================== ======================== ===============

uninstall Never Could not start

Coming from a 20+ year *nix background, may I say this is dang frustrating? :party:

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

schtasks prompted me for usr/pass before queueing...so i figured it was ok to omit..but i tried /RU /RP to see what would happen anyway..

C:\>schtasks /Create /IT /SC ONCE /TN uninstall /TR "C:\sb\testing\uninstall.bat" /ST 11:22 /RU Administrator /RP automation /Z

SUCCESS: The scheduled task "uninstall" has successfully been created.

C:\>time

The current time is: 11:21:16.01

Enter the new time:

C:\>schtasks /Query

TaskName Next Run Time Status

==================================== ======================== ===============

uninstall 11:22:00 AM, 5/29/2009

C:\>time

The current time is: 11:22:16.34

Enter the new time:

C:\>schtasks /Query

TaskName Next Run Time Status

==================================== ======================== ===============

uninstall Never Could not start

Try changing the target command line to: /TR "START C:\sb\testing\uninstall.bat"

Coming from a 20+ year *nix background, may I say this is dang frustrating? :)

You may, and Amen to that!

:party:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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