none
How to code this batch file? RRS feed

  • Question

  • I would like to know on how to delay 5 seconds before running the next line as shown below

    Does anyone have any suggestions?
    Thanks in advance for any suggestions

    @echo off
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.google.com"  < Run this first
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.yahoo.com"  < Delay 5 seconds and run this second.



    Thanks in advance for any suggestions

    Friday, December 9, 2016 11:25 AM

Answers

  • Could you please suggest on what coding look like to perform following task in powerscript?

    Do you have any suggestions?
    Thanks, to everyone very much for any suggestions :>

    @echo off
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.google.com"  < Run this first
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.yahoo.com"  < Delay 5 seconds and run this second.


    Thanks in advance for any suggestions

    Add this line to your batch file:

    powershell -command "start-sleep 6"


    \_(ツ)_/

    • Marked as answer by oemMicrosoft Saturday, December 10, 2016 12:47 AM
    Friday, December 9, 2016 4:39 PM
  • Add this line to you batch file:

    timeout /t 5 /nobreak

    or

    timeout /t 5 /nobreak >nul:


    \_(ツ)_/

    • Marked as answer by oemMicrosoft Saturday, December 10, 2016 12:47 AM
    Friday, December 9, 2016 4:41 PM

All replies

  • Hallo,

    in Batch it is sleep

    @echo off
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.google.com"  < Run this first

    sleep 5

    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.yahoo.com"  < Delay 5 seconds and run

    or in PowerShell :

    start http://www.google.com
    start-sleep -seconds 5
    start http://www.yahoo.com

    Andy

    Friday, December 9, 2016 12:49 PM
  • As far as I know there is no "sleep" in batch. If I remember right, Microsoft recommended once to ping your own client a certain times to "waste" some time in a batch script.

    You should not use batch anymore. Powershell is so much more powerfull that it does not make sense to put effort in batch scripts.


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    • Proposed as answer by FWN Friday, December 9, 2016 1:11 PM
    Friday, December 9, 2016 1:02 PM
  • You probably can run the commands in a PowerShell script, where there is a Sleep command.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Friday, December 9, 2016 1:54 PM
    Moderator
  • Could you please suggest on what coding look like to perform following task in powerscript?

    Do you have any suggestions?
    Thanks, to everyone very much for any suggestions :>

    @echo off
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.google.com"  < Run this first
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.yahoo.com"  < Delay 5 seconds and run this second.


    Thanks in advance for any suggestions

    Friday, December 9, 2016 2:09 PM
  • Could you please suggest on what coding look like to perform following task in powerscript?

    Do you have any suggestions?
    Thanks, to everyone very much for any suggestions :>

    I assume you mean Powershell instead of Powerscript, right?  ;-)

    My suggestion would be to learn Powershell from scratch. I am convinced  it will pay off for you in the future. A good starting point is the Microsoft Virtual Academy. They released a kind of video starter course: Getting Started With Powershell 3.0

    And if you had fun watching this you could also take a look at the next step: Advanced Tools & Scripting with PowerShell 3.0 Jump Start

    Have a lot of fun!


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    Friday, December 9, 2016 2:26 PM
  • Could you please suggest on what coding look like to perform following task in powerscript?

    Do you have any suggestions?
    Thanks, to everyone very much for any suggestions :>

    @echo off
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.google.com"  < Run this first
    start /b /max "IE" "C:\Mozilla Firefox\firefox.exe" "http://www.yahoo.com"  < Delay 5 seconds and run this second.


    Thanks in advance for any suggestions

    Add this line to your batch file:

    powershell -command "start-sleep 6"


    \_(ツ)_/

    • Marked as answer by oemMicrosoft Saturday, December 10, 2016 12:47 AM
    Friday, December 9, 2016 4:39 PM
  • Add this line to you batch file:

    timeout /t 5 /nobreak

    or

    timeout /t 5 /nobreak >nul:


    \_(ツ)_/

    • Marked as answer by oemMicrosoft Saturday, December 10, 2016 12:47 AM
    Friday, December 9, 2016 4:41 PM
  • Thanks, to everyone very much for suggestions :>

    Thanks in advance for any suggestions

    Saturday, December 10, 2016 12:47 AM