Question:
How would I make a Batch File to open up a few different websites with a selection screen?
double B
2012-08-23 23:29:05 UTC
I would like to make a batch file that would give you a list of websites and you can select one. Once you have the one selected, you press enter and WAZAHH! It opens. I can only make it so all of the websites open at once without a selection screen. ugh.
Four answers:
The Outcaste
2012-08-24 00:43:08 UTC
Add or change websites as needed, just keep the numbers consecutive, and no leading 0's. Be sure to adjust the Set _Num line to the number of the last site on the menu.

The page will be loaded in your default browser.



@Echo Off

SetLocal EnableDelayedExpansion

Set _D1=Yahoo

Set _U1=www.yahoo.com

Set _D2=Yahoo Answers

Set _U2=answers.yahoo.com

Set _D3=CNN

Set _U3=www.cnn.com

Set _D4=Google

Set _U4=www.google.com

Set _D5=Facebook

Set _U5=www.facebook.com

Set _Num=5

cls

Echo.Choose the website you'd like to visit

For /L %%I In (1,1,%_Num%) Do (

If %%I LSS 10 (Set _Pad= ) Else (Set _Pad=)

Echo.!_Pad!%%I - !_D%%I!

)

Set /A _Last=_Num+1

Echo.%_Last% - Type an address not listed

Echo.

:_Ask

Set _Inp=

Set /P _Inp=Enter your choice -

If "%_Inp%"=="" Goto :EOF

If %_Inp%==%_Last% Goto _Type

If %_Inp% GTR 0 If %_Inp% LSS %_Last% Goto _Open

Echo.

Echo.Please enter a number between 1 and %_Last%

Goto _Ask

:_Type

:_Ask

Set _Inp1=

Set /P _Inp1=Enter Web address:

If "%_Inp1%"=="" Goto :EOF

Set _U%_Last%=%_Inp1%

:_Open

Set _URL=!_U%_Inp%!

Start "" "%_URL%"
2016-12-10 20:27:07 UTC
You cant specify the window length with explorer, with iexplorer you need to use the -ok (kiosk) command line swap and it will bypass into finished exhibit mode, yet doubt you will like utilising that selection. Firefox supposedly has the switches for the width and height, yet cant get the two to artwork.
Jake
2012-08-24 12:32:08 UTC
This is pretty simple. It will open up in your default browser.





echo off

setlocal enabledelayedexpansion

REM enabledelayedexpansion is the only way to write variables within the FOR command...more on this later.



set URL1=www.Yahoo.com

set URL2=www.Hotmail.com

set URL3=www.Ebay.com

REM ADD AS MANY URLS AS YOU LIKE UP TO 25

REM JUST MAKE THEIR RESPECTIVE VARIABLE NUMBERS SEQUENTIAL:

REM I.E. URL1, URL2, URL3, ETC.



REM THIS LINE RESTRICT THE NUMBER OF URLS TO AT MOST 25

REM YOU CAN EDIT THIS LINE, BUT DO NOT EDIT BELOW THIS LINE

for /l %%a in (1,1,25) do (

REM this FOR command counts from 1, in increments of 1, to 25.

if not "!URL%%a!"=="" set URLcount=%%a

REM this is asking if the URL# isn't empty, then set the URLCount to that number.

REM this in turn will discover just how many URLS you have listed

for /f "tokens=2 delims=/." %%b in ("!URL%%a!") do set display%%a=%%b

REM this FOR command takes the 2 word that is separated between a "/" or a "." in the URL, and assigns it to the DISPLAY# variable. So if you put in www.yahoo.com as the url, the display word will just be yahoo.

)





set selection=1

:MainMenu

cls

title !display%selection%! Selected.

echo NAVIGATION: I UP, K DOWN, L SELECT, J QUIT

echo.

for /l %%a in (1,1,!URLcount!) do (

REM once again, this just counts from 1 to the number of URLS that you have.

if "!selection!"=="%%a" echo ^>!display%%a!^<

REM this displays the selected URL between brackets.

if not "!selection!"=="%%a" echo !display%%a!

)



choice /c iklj >nul



REM SELECT UP

if "!errorlevel!"=="1" (

set /a selection -=1

if "!selection!"=="0" set selection=!URLcount!

)



REM SELECT DOWN

if "!errorlevel!"=="2" (

set /a selection +=1

if !selection! gtr !URLcount! set selection=1

)



REM SELECT ITEM

if "!errorlevel!"=="3" start !URL%selection%!



REM SELECT QUIT

if "!errorlevel!"=="4" goto :EOF



goto :MainMenu
2012-08-23 23:46:58 UTC
I got this. I took 5 min to write this and it totally works! Just paste this into the code after getting rid of everything:



EDIT: It only supports Google Chrome, Internet Explorer, and Mozilla Firefox



Or download it here(It passed my virus check XD): http://www.herosh.com/download/10938107/webexplore.zip.html



Remember, I wrote it so don't take ownership for it please.



@echo off

@title Web opener

@color ca



:welcome

echo Welcome! What is your browser?

echo Type 1 for Internet Explorer

echo Type 2 for Google Chrome

echo Type 3 for Mozilla Firefox

set /p input=

if %input%==1 goto IE

if %input%==2 goto GC

if %input%==3 goto MF

pause

goto welcome



:IE

cls

echo Please type your web address(Include www. and .com):

echo Example: Must be full: www.google.com

set /p input=

start iexplore %input%

pause

goto IE

cls



:GC

cls

echo Please type your web address(Include www. and .com):

echo Example: Must be full: www.google.com

set /p input=

start chrome %input%

pause

goto GC

cls



:MF

cls

echo Please type your web address(Include www. and .com):

echo Example: Must be full: www.google.com

set /p input=

start firefox %input%

pause

goto MF

cls


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...