Script - IE and others

Discussion in 'Scripting' started by John, Apr 2, 2009.

  1. John

    John Guest

    Hello everyone,

    Does anyone knows how to script IE or other existing browsers in a given
    server?

    Here's What I'm trying to:
    I have a schedule tasks that runs every 2 min, in that batch there're some
    things to do, and if one of those things fail, it writes the results to a log
    and additionally I would like to open a URL that will trigger another action
    in a remote server.

    I already used the "start Iexplore.exe www.something.com/fgfgfgfgfjjjhk/..."
    the problem is that once the IE is open it stays open, and every time that
    the command "start Iexplore.exe www.something.com/fgfgfgfgfjjjhk/..." is
    called from the batch file, it opens a new window!!!

    Does anyone has a alternative solution to me needs? It doesn't have to be
    the Iexplore.exe, I could use any other tool that allows me to call a URL and
    after a given time that URL should be closed.


    Thank you for your time.
     
    John, Apr 2, 2009
    #1
    1. Advertisements

  2. A crude but effective method would be to use taskkill.exe to kill
    iexplore.exe 60 seconds after you've launched it.
     
    Pegasus [MVP], Apr 2, 2009
    #2
    1. Advertisements

  3. John

    John Guest

    Hi Pegasus

    Thank you for the fast response, but how do I know what PID is associated to
    that specific process?

    Do you know other methods or tools to do this?
     
    John, Apr 2, 2009
    #3
  4. You need to look for the process that runs your web page, e.g. like so:
    1. @echo off
    2. start /b "Explorer" "C:\Program Files\Internet Explorer\iexplore.exe"
    www.google.com
    3. ping localhost -n 60 > nul
    4. for /F "tokens=2" %%a in ('tasklist /v ^| find /i "google"') do set
    PID=%%a
    5. if not "%PID%"=="" (
    6. echo Killing process %PID%
    7. taskkill /pid %PID%
    8. )
     
    Pegasus [MVP], Apr 2, 2009
    #4
  5. John

    John Guest

    Thank you, I'll git it a try.

     
    John, Apr 2, 2009
    #5
  6. You will want to use vbscript to open IE, you can then easily navigate
    to the internal web page, wait however long you need and then close IE.
    Here is the code you need.
    Code:
    '=======================================================================
    ===
    '
    ' NAME:
    '
    ' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
    ' URL: http://www.thespidersparlor.com
    ' DATE  : //2009
    ' COPYRIGHT © 2009, All Rights Reserved
    '
    ' COMMENT:
    '    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
    '    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
    '    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
    '    PARTICULAR PURPOSE.
    '
    '    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE
    SUPPLIERS
    '    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
    '    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
    '    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
    '    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
    '    OF THIS CODE OR INFORMATION.
    '
    '=======================================================================
    ===
    Dim objIE
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Visible = False
    objIE.Navigate "http://www.thespidersparlor.com"
    objIE.Visible = True
    'Wait 10 seconds (number in milliseconds)
    WScript.Sleep 10000
    'Now close IE
    objIE.Quit
    
    --
     
    Mark D. MacLachlan, Jul 1, 2009
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.