Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a list of websites. I want a batch file which will open only first website in the list when i execute the bat file for first time and when i execute the batch file for second time it will open only the second website in the list and when i execute it for third time it will open only third website in the list and so on.

Didn't we go through this a couple days ago?
=====================================
If at first you don't succeed, you're about average.M2

Hi Mechanix2Go,
I did tried with following answer:
@Echo off
Set /a TimesRun=%TimesRun%+1If %TimesRun% == 1 "C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab
http://google.com
If %TimesRun% == 2 "C:\Program Files\Mozilla Firefox\firefox" -new-tab http://yahoo.com
If %TimesRun% == 3 "C:\Program Files\Mozilla Firefox\firefox" -new-tab http://cnn.com
If %TimesRun% gtr 4 Set /a TimesRun=0But everytime i executed this .bat file I ended with a firefox window with www.google .com tab at each and every execution.
Can you explain me what is wrong here.

sorry, retyping again because i forget .exe suffix with firefox, nevertheless i am getting same result with following .bat script.
Hi Mechanix2Go,I did tried with following answer:
@Echo off
Set /a TimesRun=%TimesRun%+1If %TimesRun% == 1 "C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab
http://google.com
If %TimesRun% == 2 "C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab http://yahoo.com
If %TimesRun% == 3 "C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab http://cnn.com
If %TimesRun% gtr 4 Set /a TimesRun=0But everytime i executed this .bat file I ended with a firefox window with www.google .com tab at each and every execution.
Can you explain me what is wrong here.

For a bat to know where it left off, not much choice but to write a file.
===========================
@echo off & setLocal EnableDELAYedExpansionif not exist %TEMP%\runnum echo 1> %TEMP%\runnum
set /p R=<%TEMP%\runnum
set N=for /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1
if !N! equ !R! echo firefox %%a blabla
)
set /a R+=1
echo !R!> %TEMP%\runnum
=====================================
If at first you don't succeed, you're about average.M2

thanks for quick response, Mechanix2go.
But I can not put it to be useful for my purpose myself alone because i don't know anything about batch or for that matter any sort of programming unless someone feeds me with silver spoon.
So please do provide me a step by step guide telling me how to proceed from scratch to finish.
make it for me a copy and paste work.
your effort will be duly appreciated.
(As for the batch script i provided to make a solution of my problem, was also a copy and paste work with the script provided to me by a user named ace_omega at this forum.)regards.

The only thing you need to change is the line below to make firefox do what you want:
if !N! equ !R! echo firefox %%a blabla
=====================================
If at first you don't succeed, you're about average.M2

Thanks,Mechanix2Go
But I am confused about myfile in the line below:or /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1Which myfile do you referring here. What I did I put following text in a notepad, named it sequential execution.bat and then double clicked the same bat file but nothing happened:
@echo off & setLocal EnableDELAYedExpansion
if not exist %TEMP%\runnum echo 1> %TEMP%\runnum
set /p R=<%TEMP%\runnum
set N=for /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1
if !N! equ !R! echo "c:\program files\mozilla firefox\firefox.exe" %%a -new-tab http://google.com -new-tab http://yahoo.com -new-tab http://cnn.com
)
set /a R+=1
echo !R!> %TEMP%\runnumPlease have patience with me and be little bit more elaborative. It will be a great help if you provide me a scratch to finish text of workable script supposing I have list of 10 websites like http://google.com, http://yahoo.com and so on.
Regards.

Thanks to Mechanix2go,
Following suggestion on another site worked for me.@echo off
setlocal enableextensions
rem fetch the first URL
set /p URL=<list.txt
rem Open the browser with that URL
start "" "%URL%"
rem Remove the URL from the front of the file ...
more +1 list.txt | findstr /r /v "^$" > tmp_list.txt
rem ... and put it to the end
echo.%URL%>>tmp_list.txt
del list.txt
ren tmp_list.txt list.txt
endlocal

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |