Jump to content

Recommended Posts

Posted

I have a script that launches a backup program by opening an associated "job" file. When this window becomes active, the script clicks the "Run" button, the job runs, showing its status in a new window. When this window shows the "Job finished" message, the script closes the job execution window and the main program window. The script is tied to a task in Windows Task Scheduler on a machine that I remote desktop into. It is scheduled to run at 1:00 AM when nobody is using the box. The account is left logged onto the machine pretty much all of the time.

It runs just fine when I execute it "live". However, when it runs via Task Scheduler, the main program window opens, but then apparently loses focus and sits until someone remotes in and then clicks on the window.

Below is a sample of the code. I have changed the name of the application, as I am trying to cheat a full backup out of a trial version that only lets you schedule a partial backup.

This is the latest variation that I have tried. It is sloppy I know...desperation.

Can anyone help me?

Opt("WinTitleMatchMode", 2)

ShellExecute("BackUp.job", "","[PATH]")

WinActivate("Backup Application Title")

WinWaitActive("Backup Application Title")

ControlClick("Backup Application Title", "", "Run")

WinWaitActive("Job Execution Status", "Job finished")

WinClose("Job Execution Status")

WinWaitClose("Job Execution Status")

WinActivate("Backup Application Title")

WinWaitActive("Backup Application Title")

WinClose("Backup Application Title")

PK

Posted

Excellent question.

It does indeed have command line support, but this lauches the limited version and only does a partial backup.

I have to initiate the backup via the GUI to get a full backup.

PK

Posted

It looks like you only do winwaitactive you could try looping WinExists("Backup Application Title") every second then when it finds it then do a winactive to see if that helps.

Posted

That was a prrtty good idea. I modfied the code to look like this. Same behavior. The window opens, but loses focus and the script sits idle until I log in and click it.

Opt("WinTitleMatchMode", 2)

ShellExecute("BackUp.job", "","[PATH]")

Do

Until WinExists("Backup Application Title")

WinActivate("Backup Application Title")

WinWaitActive("Backup Application Title")

ControlClick("Backup Application Title", "", "Run")

WinWaitActive("Job Execution Status", "Job finished")

WinClose("Job Execution Status")

WinWaitClose("Job Execution Status")

WinActivate("Backup Application Title")

WinWaitActive("Backup Application Title")

WinClose("Backup Application Title")

Posted

Well, after some testing at home this weekend, apparently the culprit is Windows Task Scheduler. If i use a third party scheduler (System Scheduler), it seems that the window does not lose focus if it runs while the PC is locked.

Anyone have any ideas? I really did not want to use a third party scheduler. Can anyone reoommend one? When i tried to install System Scheduler at work, our Symantec AV did not like it and would not let me.

pk

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
  • Recently Browsing   0 members

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