Jump to content

task scheduler question


Recommended Posts

Hi i am new here, and i wanted to see what a amazing program Autoit is.

I used it yesterday and it works like a charm, only 1 problem is coming up.

I have a script, what it does is, it load cmd.exe and than loads a dos program, in that dos program it uses keystrokes to make a backup of the programs database.

After that it closes the program and uploads the backup (csv file) to a ftp server.

This all works perfectly, i compiled the script, and when i press it, it totally works.

Then i tried to put it in task scheduler and it didn't work, so i made a shortcut to the compiled script and put that in task scheduler, that worked.

At a certain time task scheduler performs the task great but now comes the problem, it only performs the task when someone is logged in.

After i log out from the (2003) server, it does not perform the task, the task scheduler gives the 0x1 error adn the task is not done.

I do not know why, has it something to do with the script ?

Can someone help me with this or am i on the wrong forum ?

Maybe there is a way to place a command in task scheduler to log in and than run the script and than log out again, i don't know if that is even possible

Edited by MarkDekker
Link to comment
Share on other sites

When you use your script to simulate user input and output it is only natural that Windows requires a user to be logged in. Because; How can a user perform input and output without being logged in? Answer: It can't, so your script can not either.

Your task is simple, though, and doesn't require any user interaction at all. Console applications can be automated using more devious contraptions, such as standard streams and parameters. There is a library available for direct FTP connections from your script.

Link to comment
Share on other sites

Hi thank you for your answer.

So you mean it is never possible for my script to work ?

So it is not possible to automate a login and than load the script ?

The dos program cannot be activated by any other means than that someone presses enter, logs in and goes to the right menu to activate a backup.

The FTP thingy in my script is not really a problem because that is the one that works, but the most important thing is for the program to make a backup, i do not see how else this could be done.

Link to comment
Share on other sites

When i am logged on, and i see the desktop and the script runs, it runs completely.

When i am remotely logged in, and i see the desktop and the script runs, it runs completely.

But when i am remotely logged in, and i minimize the screen, and the script runs, it stops.

How is this possible ?

Link to comment
Share on other sites

Hi i thought i had the perfect script.

It loaded my DOS program and automatically (through keystrokes) it made a backup.

I want that program to do that every day.

But how ?

My script works but not when the script is automated, i cannot put it in a Task Scheduler because it is a console application, so how do i do it ?

Link to comment
Share on other sites

  • Moderators

Verbal warning:

Don't double post the same question. Be patient and wait for a reply with your original one.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Verbal warning:

Don't double post the same question. Be patient and wait for a reply with your original one.

My apologies, i was not being patient, i just want a quick answer but i will wait.

Make another one that starts the first and puts the parameters. You can put the second one in the task scheduler.

How can i do that, i already tried to load the script from a batch file, that didn't work, than i tried a shortcut, that only works when the machine is logged in, and the actual desktop is shown.

Maybe i should rephrase my question :-)

I have a 2003 server, the computer is logged off in the night, normally i manage everything through a remote desktop but my boss wants a script that automates everything i do.

We have our shop program, which is a 2005 DOS program, that has a gui, and is operated with the keyboard.

Inside the program you have to go inside a menu to make a backup.

That backup can be automated using a script.

I already made such a script.

When i click it, it starts the program and than it makes a backup.

It shuts off, than loads up a FTP connection and uploads the backup to the FTP.

Like i said, this all works.

When i put a shortcut to the compiled script in the task scheduler, it works, BUT it only works when i am logged in to the machine and i see the actual desktop.

When i log off the script won't run, which would be logical 'cause it is a graphical gui which needs user input.

But how do i solve this, would this just be so simple to load the script from another script.

Can someone helpe me with this, i think there would be more people in the world that has this problem.

Link to comment
Share on other sites

"I have a 2003 server, the computer is logged off in the night" - you should have started with that.

I think the easiest thing is to install your script as a service.That way it will work when no user is logged on.

You may consider creating one user and leaving it always logged on - just locking the PC.

Link to comment
Share on other sites

You can implement timing with functions like _Date_Time_GetSystemTime.

And you can change the Send() functions to ControlSend(). That way it will work.

As there will be no user logged in - what user input are you talking about ?

I dont remember exactly but i think no GUI was possible if there is no user currently logged in.

I think it was possible to workaround that with the RunsAs() function.

Link to comment
Share on other sites

I meant that normally the program requires user input, the program has a gui that is operated with the keyboard.

So the script has to automate that input.

During the night, no user is logged in on the server, all the users are logged off or/and the administrator is locked.

I also tried a program that auto logs in to my desktop but that failed also.

Here is the script for the program, i have to change the send into ControlSend ???

$app = "c:\data\vmsii\VMSII.exe STATION=a DRIVEPATH=C:\data\VMSII f=1"
run("cmd")
sleep(2000)
WinActivate("C:\WINDOWS\system32\cmd.exe", "")
WinActivate("Customrun")
Send( "c:\tame\tame /Uninstall" & "{ENTER}")
sleep(10000)
send($app & "{ENTER}")
sleep(68000)
Send("2602{Enter}")
sleep(10000)
Send("{RIGHT}" & "{RIGHT}" & "{enter}")
sleep(5000)
Send("{down}" & "{down}" & "{down}" & "{down}" & "{down}" & "{enter}")
sleep(5000)
Send("0000{Enter}")
Send("9999{Enter}")
sleep(5000)
Send("{enter}" & "{enter}" & "{right}" & "{right}" & "{right}" & "{enter}" & "{enter}")
sleep(5000)
Send("c:\data\web.txt{Enter}")
sleep(5000)
Send("|{enter}")
Send("n{enter}" & "{enter}" & "{enter}")

Edited by MarkDekker
Link to comment
Share on other sites

I tried to replace Send into Controlsend but the script still doesn't run as a background service

$app = "c:\data\vmsii\VMSII.exe STATION=a DRIVEPATH=C:\data\VMSII f=1"
run("cmd")
sleep(2000)
WinActivate("C:\WINDOWS\system32\cmd.exe", "")
WinActivate("Customrun")
Controlsend( "c:\tame\tame /Uninstall" & "{ENTER}")
sleep(10000)
Controlsend($app & "{ENTER}")
sleep(68000)
Controlsend("2602{Enter}")
sleep(10000)
Controlsend("{RIGHT}" & "{RIGHT}" & "{enter}")
sleep(5000)
Controlsend("{down}" & "{down}" & "{down}" & "{down}" & "{down}" & "{enter}")
sleep(5000)
Controlsend("0000{Enter}")
Controlsend("9999{Enter}")
sleep(5000)
Controlsend("{enter}" & "{enter}" & "{right}" & "{right}" & "{right}" & "{enter}" & "{enter}")
sleep(5000)
Controlsend("c:\data\web.txt{Enter}")
sleep(5000)
Controlsend("|{enter}")
Controlsend("n{enter}" & "{enter}" & "{enter}")

Link to comment
Share on other sites

Okay thanks, i am reading it now, but still don't understand certain things.

You said before that it is not possible to load a script that runs a dos application with gui.

Other people say it can be done, so i am little confused if, what i want, is possible, because i cannot find any answer on the web about this, and i must not be the only one that has this problem.

By the way, i succesfully altered the script so that it runs with ControlSend, cannot understand exactly why it would run better with ControlSend because the help file says that it is unpredictable with command prompts, either way, it doesn't work when i load it into the task scheduler.

$app = "c:\data\vmsii\VMSII.exe STATION=a DRIVEPATH=C:\data\VMSII f=1"
run("cmd")
sleep(2000)
WinActivate("C:\WINDOWS\system32\cmd.exe", "")
WinActivate("Customrun")
controlsend( "","","","c:\tame\tame /Uninstall")
controlSend("","","","{ENTER}")
sleep(5000)
controlSend("","","",$app)
controlSend("","","","{ENTER}")
sleep(34000)
ControlSend("","","","2602{Enter}")
sleep(5000)
ControlSend("","","","{RIGHT} & {RIGHT} & {enter}")
sleep(5000)
ControlSend("","","","{down} & {down} & {down} & {down} & {down} & {enter}")
sleep(5000)
ControlSend("","","","0000{Enter}")
ControlSend("","","","9999{Enter}")
sleep(5000)
ControlSend("","","","{enter} & {enter} & {right} & {right} & {right} & {enter}")
sleep(2000)
controlSend("","","","{ENTER}")
sleep(5000)
ControlSend("","","","c:\data\web.txt{Enter}")
sleep(5000)
ControlSend("","","","|{enter}")
sleep(5000)
ControlSend("","","","n{enter} & {right} & {enter} & {enter}")

Edited by MarkDekker
Link to comment
Share on other sites

"During the night, no user is logged in on the server, all the users are logged off or/and the administrator is locked."

If the "administrator is locked" your script should work when you put it in the task scheduler.Have you tried that?

Link to comment
Share on other sites

Hi, yes i did, but it just loads the cmd.exe and than stops, after a few minutes the script ends and than the task scheduler says it is completed.

I tested this also by remote desktopping, i log in, i see the task scheduler load up the script, and when i then minimize the remote desktop screen and maximize it after a couple of minutes, it is the same thing, the cmd.exe is loaded but nothing happened.

Is it my script or this computer ?

The Administrator could also be logged of instead of being locked, i will try this.

Link to comment
Share on other sites

Then it seems there is something wrong with your script.

If you are logged on the PC with the administrator account at the moment the tasksheduler starts the script

does it work? Please post here the full script that you have.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...