Jump to content
Sign in to follow this  
clee01l

Scheduled Tasks that call IE hang.

Recommended Posts

clee01l

I have a nightly process that copies files to a server and then runs a PHP process to catalog those files.

If I use _IECreate, the task hangs at the _IECreate step ONLY when run as a scheduled task.

Originally the Task was scheduled with the user being NTAUTHORITY/SYSTEM Thinking that might be the problem, I created a local user with sufficient authority to run the task. The results were the same.

When I tried the scheduled task using ShellExecuteWait instead of _IECreate, the task does not hang, but I can not detect when the Browser control has been returned from the server. (i.e. Status = "Done") Also, the scheduled task will now run to completion and end , but iexplore.exe is still an active process. How can I tell when the PHP process on the server has finished and how can I stop the Shell process ( the equivalent of _IEQuit)? Is there some trick to getting _IECreate to run as a scheduled task?

During the task I am Logging the results. Here are some log snippits:

(When logged in as a user)

2008-04-08 12:45:17 : Files were Exported to: /data/users/gccftp/gccftp

2008-04-08 12:45:17 : http://gcc.shis.uth.tmc.edu/helpers/import...:34::NONE::::::

2008-04-08 12:45:28 : The browser was closed

__________________________________________________________________________________

(When Run as a scheduled task)

2008-04-09 08:41:00 : =======================================================================================

2008-04-09 08:41:00 : Began Execution of C:\GCCexport\GCCexport.exe

2008-04-09 08:41:00 : Files: 14 :: Dirs: 1 to be Exported.

2008-04-09 08:41:00 : $runCommand = C:\GCCexport\winscp.exe /console /script="C:\GCCexport\GCCscript.scp" "gccftp@129.106.149.39"

2008-04-09 08:41:20 : Program returned with exit code: 0

2008-04-09 08:41:20 : Files were Exported to: /data/users/gccftp/gccftp

2008-04-09 08:41:20 : http://gcc.shis.uth.tmc.edu/helpers/import...:34::NONE::::::

__________________________________________________________________________________

(Using ShellExecuteWait instead of _IECreate)

2008-04-09 09:02:42 : Files were Exported to: /data/users/gccftp/gccftp

2008-04-09 09:02:42 : http://gcc.shis.uth.tmc.edu/helpers/import...:34::NONE::::::

2008-04-09 09:02:44 : ShellExecute returned with exit code: 100

Using _IECreate

$url = "http://gcc.shis.uth.tmc.edu/helpers/importer.php?foldername=" & $BioTrueUser & "&ticket=5::" & $BioTrueLabID & "::" & $BioTrueProjectID & "::NONE::::::"
    If $doLog Then
        _FileWriteLog($logFile, $url)
    ;MsgBox(4096, "URL" , $url)
    EndIf   
    $oIE = _IECreate($url, 1)
    $sIEstatus = _IEPropertyGet($oIE, "statustext")
    If $doLog Then
        _FileWriteLog($logFile, $sIEstatus)
    EndIf
    If $sIEstatus == "Done" Then
    ;;;;    Close the Browser;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        $rtn = _IEQuit($oIE)
        If $rtn Then
            If $doLog Then
                _FileWriteLog($logFile, "The browser was closed")
            ;MsgBox(4096, "URL" , $url)
            EndIf
        EndIf

Using ShellExecuteWait

$val = ShellExecuteWait($url)
    If $doLog Then
        _FileWriteLog($logFile, "ShellExecute returned with exit code: " & $val)
    EndIf
    If $val Then

Share this post


Link to post
Share on other sites
TheCreator

Something I can think of, and it may not be the best solution, is make your php page redirect, or capture info from the page, every second or so.

As for your IE not closing, you can close iexplore, if you get the pid when it's created. and close that in case you happen to have an IE process running at the time when you run the scheduled task.


~~TheCreator~~Visit http://tysdomain.com for personal software and website solutions.

Share this post


Link to post
Share on other sites
clee01l

Something I can think of, and it may not be the best solution, is make your php page redirect, or capture info from the page, every second or so.

As for your IE not closing, you can close iexplore, if you get the pid when it's created. and close that in case you happen to have an IE process running at the time when you run the scheduled task.

I don't have control over the PHP process. I have to submit the URL with a querystring as shown in the code and wait. The PHP/HTTP does no screen display and only returns a status of "Done" when complete. The process initiated by the PHP script can take a few minutes to a few hours. I need to know when the server process finishes before I can close IE and before I can continue.

Share this post


Link to post
Share on other sites
DaleHohm

Why are you waiting for the status text to be "Done"? _IECreate calls _IELoadWait for you and insures that the page load is done before it returns control to the next line of script.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
clee01l

Why are you waiting for the status text to be "Done"? _IECreate calls _IELoadWait for you and insures that the page load is done before it returns control to the next line of script.

Dale

Uncertainty about what _IELoadWait actually does and that this AutoIT application was converted from a PERL Script that needed the same logic are the reasons that I check the Status before continuing. The PHP script runs a background task that may take minutes to hours to complete. When I run this as a logged on user, the browser paints a screen with an empty <html><html> long before the Status= "Done" messages appears.

This still does not address the more important issue of why the AutoIT compiled script hangs when the process is run as a scheduled task unless there is no status message since there is no browser window.

Edited by clee01l

Share this post


Link to post
Share on other sites
DaleHohm

Never tried it, but suggest you don't rely on the status message.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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.