Jump to content

task scheduler problems starting a program


Recommended Posts

I have written and autoit script and it works perfectly. 

However I need it to run using windows task scheduler.  The first thing it does is open up a Microsoft access database. 

I use the shellExecute command to open the database
ie ShellExecute("\\myServer\Data\Documents\Reports.accdb")

However when I run the script from the windows task scheduler the access database does not open. The rest of the script runs fine.

How do I get this to work?

Thanks
Simon

Link to comment
Share on other sites

Does the scheduled task run under your userid?

If - as an experiment - you try to run some other command via ShellExecute, does that work?

Can you tell, eg from the OS's event logs whether Access is starting and then failing to open

your database, or whether Access itself doesn't start?

 

Edited by JeremyNicoll
correct typo
Link to comment
Share on other sites

I have discovered that it will run if I select the option "Run only when the user is logged on" but it wont run if I select "run whether the user is logged on or off"

So I have take the first option, but things sill wont run properly.  It runs on a server and I log in via remote desktop.  If I keep the window open/active everything works fine.

But If I minimise the active window then the ShellExecute command still works (and loads access) but the rest of the script fails to run.  I am running out of ideas and any suggestions would be appreciated.

Thanks Simon

Link to comment
Share on other sites

The rest of the script are a few sends.  The purpose of the script is to automatically generate a report.  The access database is hooked to a SQL server database and I need to enter the SQL server password to generate the report.  That is the idea of the send commands. 

What happens now is MS access opens but none of the send commands work.

Simon

Link to comment
Share on other sites

There is an MSaccess UDF. Did you try with that? Usually SEND commands are lame and prone to errors. Try to change them to ControlSend and error checking. Also it very much depends on how you setup the task to run , with which account , etc.

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...