Results 1 to 5 of 5

Thread: batch file to open 2 progs with time delay

  1. #1
    Join Date
    Jul 2006
    Posts
    442

    batch file to open 2 progs with time delay

    Can anyone tell me how to write a batch file to open 2 programs, the first to open immediately and the second one with a 20 second delay after the first one? Like for example, I would like to open Google Earth first and then want to open another programs Event Manager 20 seconds after Google Earth? How can I do that? Thanks.

  2. #2
    Join Date
    Oct 2005
    Posts
    449

    Re: batch file to open 2 progs with time delay

    You can try to start a script file from the bat file, and use the argument to wait till it returns. This could be a script that waits 20 seconds before returning.

    ---example.bat--
    start first.exe
    start /wait myscript.vbs
    start second.exe
    --end file--

    --myscript.vbs
    wscript.sleep 20000
    --end file--

  3. #3
    Join Date
    Oct 2004
    Posts
    1,342

    RE: batch file to open 2 progs with time delay

    I dont think it is possible by batch commands, but a very simple script will do this:

    ; Delay.au3
    ; Compile with AutoIt 3.x, http://www.techarena.in
    ; Usage in batch: Delay {seconds}

    Opt ("TrayIconHide",1)

    if $cmd[0] > 0 then
    $thisDelay=$cmd[1] * 1000
    sleep($thisDelay)
    endif
    exit

  4. #4
    Join Date
    Jan 2006
    Posts
    605
    You can try to copy and paste the below into notepad (don't use Word or Wordpad) and save it as "Abc.bat"

    start "C:\Program Files\Google\Google Earth Pro\googleearth.exe"
    echo wscript.sleep 20000 > temp.vbs
    start /wait temp.vbs
    start "C:\Documents and Settings\Andrew\Desktop\DUMP\EventManager\EventManager.exe"
    del temp.vbs

  5. #5
    Join Date
    Jan 2006
    Posts
    4,545
    You can try to use a visual basic script instead. Just copy and paste the below in notepad and save it as "Abc.vbs":

    dim oShell
    Set oShell=WScript.CreateObject("WScript.Shell")

    oShell.Run "calc.exe",1,false
    wscript.sleep 20000
    oShell.Run "notepad.exe",1,false

    If it works, replace "calc.exe" and "notepad.exe" with your complete programs' paths and names.

Similar Threads

  1. Learning Batch file to open a program or a file
    By Ikshana in forum Windows Software
    Replies: 3
    Last Post: 04-04-2011, 07:24 PM
  2. How to run batch file at specific time
    By Campbel in forum Software Development
    Replies: 4
    Last Post: 27-03-2010, 07:32 PM
  3. How to run batch file each time computer boots
    By Gannon in forum Software Development
    Replies: 4
    Last Post: 27-03-2010, 05:53 PM
  4. Replies: 2
    Last Post: 26-05-2009, 10:41 AM
  5. Date and Time format in a BATCH File
    By RogerFielden in forum Software Development
    Replies: 3
    Last Post: 20-04-2009, 11:47 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,564,092.59766 seconds with 17 queries