Jump to content
Sign in to follow this  
legoman74

Script not running on remote server (win 2003)

Recommended Posts

legoman74

I have created a script to log into an application (Meditech) and run a report. I then use a Windows Scheduled Task to get it ot run at 5 am. The script works great when I am logged into the Windows 2003 server but won't run when I'm not watching it. I read the FAQ article about remote servers and changing the script to use ControlSend etc but when I changed it the script didn't run at all. Can someone help me rewrite my scipt so it will work on the remote server?

here it is:

#region ---Au3Recorder generated code Start ---

Opt("WinWaitDelay",1000)

AutoItSetOption("SendKeyDelay", 10) ; default 5

AutoItSetOption("SendKeyDownDelay", 2) ; default 1

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

_WinWaitActivate("Start Menu","")

MouseClick("left",24,414,1)

MouseClick("left",206,253,1)

_WinWaitActivate("Run","")

Send("c:\program{SPACE}files\meditech\magiccs\client\csmagic.exe{ENTER}")

_WinWaitActivate("Meditech Health Care Information System","")

Send("mcurrie{TAB}{SHIFTDOWN}P{SHIFTUP}assword00{TAB}{BACKSPACE}{F9}{ENTER}")

_WinWaitActivate("MICHAEL J CURRIE","")

Send("{DOWN}{DOWN}{DOWN}{ENTER}")

_WinWaitActivate("NPR Database - MICHAEL J CURRIE","")

Send("{DOWN}{DOWN}{RIGHT}{ENTER}adm.pat{TAB}{RIGHT}cgmh.currm.ed.pip.daily.detail{ENTER}")

Send("5{ENTER}")

_WinWaitActivate("Collingwood Admissions **LIVE** - MICHAEL J CURRIE","")

Send("{ENTER}{ENTER}{ENTER}{F12}")

_WinWaitActivate("NPR Database - MICHAEL J CURRIE","")

Send("{ESC}{ESC}{ESC}")

#region --- Internal functions Au3Recorder Start ---

Func _WinWaitActivate($title,$text,$timeout=0)

WinWait($title,$text,$timeout)

If Not WinActive($title,$text) Then WinActivate($title,$text)

WinWaitActive($title,$text,$timeout)

EndFunc

#endregion --- Internal functions Au3Recorder End ---

#endregion --- Au3Recorder generated code End ---

Thanks

Mike C

Share this post


Link to post
Share on other sites
LurchMan

Is the remote server logged in while trying to run this? I can't see anything obviously wrong with your script otherwise.


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites
legoman74

Yes I leave the server logged in. The user has fulladmin rights to the box.

Share this post


Link to post
Share on other sites
LurchMan

Not trying to beat a dead horse, but the server isn't locked either right? If isn't not locked then, add some error checking to find out where its failing.

Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites
legoman74

No, I never have to unlock when I go back into it....I wonder if my desktop session goes to sleep/hibernates or something. When I check it at 8:30, my script is paused and I have the little icon down in the right taskbar but the job never finishes.

Share this post


Link to post
Share on other sites
LurchMan

Then most likely its one of the WinWaitActive () calls. It must not be finding the window so its waiting (indefinitely) for that window to become active. Might want to consider stepping through it without the script to make sure all the window titles are correct in your script.

Edit: Looked closer at your script, give me a bit I'll add another edit in a few.

Edit2: Try the code below:

#region ---Au3Recorder generated code Start ---
Opt("WinWaitDelay",1000)
AutoItSetOption("SendKeyDelay", 50) ; default 5
AutoItSetOption("SendKeyDownDelay", 2) ; default 1
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)

Opt ("WinTitleMatchMode", 2) ;;*******Matches any substring from title with givin name

;~ _WinWaitActivate("Start Menu","")
;~ MouseClick("left",24,414,1)
;~ MouseClick("left",206,253,1)
;~ _WinWaitActivate("Run","")
;~ Send("c:\program{SPACE}files\meditech\magiccs\client\csmagic.exe{ENTER}")

Run ("c:\program files\meditech\magiccs\client\csmagic.exe")

_WinWaitActivate("Meditech Health Care Information System","")
Send("mcurrie{TAB}Password00{TAB}{BACKSPACE}{F9}{ENTER}")
_WinWaitActivate("MICHAEL J CURRIE","")
Send("{DOWN 3}{ENTER}")
_WinWaitActivate("NPR Database - MICHAEL J CURRIE","")
Send("{DOWN 2}{RIGHT}{ENTER}adm.pat{TAB}{RIGHT}cgmh.currm.ed.pip.daily.detail{ENTER}")
Send("5{ENTER}")
_WinWaitActivate("Collingwood Admissions **LIVE** - MICHAEL J CURRIE","")
Send("{ENTER 3}{F12}")
_WinWaitActivate("NPR Database - MICHAEL J CURRIE","")
Send("{ESC 3}")

#region --- Internal functions Au3Recorder Start ---
Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc
#endregion --- Internal functions Au3Recorder End ---

#endregion --- Au3Recorder generated code End ---
Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites
legoman74

Thanks for all of your help Lurchman, I figured it was a WinWaitActive() issue. I can run it and watch it open Meditech and log in for me and then open the report, run it and close out of the program.

Share this post


Link to post
Share on other sites
LurchMan

Good to hear, you're welcome.


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites
legoman74

I'll schedule it and see if it completes on its own. BTW, Do you know if there is way to schedule it without using Windows Scheduled Tasks?

Share this post


Link to post
Share on other sites
LurchMan

I'll schedule it and see if it completes on its own. BTW, Do you know if there is way to schedule it without using Windows Scheduled Tasks?

Not sure how other people do it, but this is how I've created my own scheduler:

#include <date.au3>

While 1
    $CurrTime = _NowTime (5)
    If $CurrTime > "01:10:00" Then $lpcnt = 0
    If $lpcnt < 1 Then
        If $CurrTime >= "01:00:00" And $CurrTime <= "01:10:00" Then ;Time is in 24 hour format Decrease gap if script takes less than 10 mins.
                  ;Call Function**********************************************
        EndIf
    EndIf
    Sleep (1000*60)
WEnd
Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.