This tutorial is a beginners tutorial for making a web portal in BATCH. When I say beginner, I am assuming that you already have some basic knowledge of BATCH. You should be familiar with "echo", "ping localhost", variables, and other commands on that level of knowledge.
If your still here, lets get started.
0) The Websites
1) Creating the user interface/menus
2) Creating the portal sections
3) Putting it all together
The first step in creating a BATCH web portal is to know what websites you want to include in the portal - otherwise it is fairly useless. So, get together a list of all the websites you want to include. Then, divide the websites up into basic categories: if I have 3 websites about history, 17 websites involving games, and a few other websites with free e-books, I would want to divide them into a History category, a Gaming category, and an E-Book category.
OK: were ready for the programming part. The first step in this process is to create the main menu and the category-specific menus. It is nice to have a neatly organized user interface, just because the program is easier to use. That said, the menus can still be pretty simple;
REM this is the part of the menu that the users see; notice the :mainmenu label and the way some of the "echo" commands only have a dot, to make things easier to read for the user. Again, just stuff to make it more accessible. :mainmenu echo . echo MAIN MENU echo ......................... echo 1 - History Portal echo 2 - Gaming Portal echo 3 - E-Book Portal echo 4 - Exit Program REM this next part is where you define the variable. set /p port= Your Portal:
Thats it for the part of the menu the user can see; for the other part, your going to use the "if" command, as well as the "goto :somelabel" command. This next part basically just says: if the user entered the number 1, go to the history portal menu, etc. Otherwise, return an error message saying "that wasn't one of the options." You don't need the error message, it just makes it easier for the user to interact with the program. So the next part should look something like this:
REM basic "if this, do some command" stuff. Note that for each option on the menu, you want to have a corresponding "if ____ do ____" command here. REM the EQU command means "equals to" if %port% EQU 1 goto :historyport if %port% EQU 2 goto :gamingport if %port% EQU 3 goto :ebookport if %port% EQU 5 goto :exit REM the GEQ command means "greater or equal to" if %port% GEQ 6 goto :error REM notice this part on the bottom that doesn't have an "if ____" attached to it. This is because BATCH programs just go down the line of commands, so if the user specifies something that you didn't include in the menu, it will just go to the error message. goto :error
OK, that's it for the main menu. Now you have to create the category specific menus. For each category, you should create a menu - if someone selects the History Portal on the main menu, it should take them to a History menu with a list of the websites. The category specific menus will contain the actual web addresses, and to make it easier to use you will list each site name and take the user straight to that website when they select it. So the code for the next part should look like the main menu code, but in the "if _____ goto :somelabel" section, you will instead have "if _____ goto some-website.com".
:ebookport REM This "ping localhost" command isn't necessary for the program to work. However it is nicer than inserting pauses every second line which makes the user need to repeatedly press his keyboard. REM Also note the path after the "-n 2 > " - without that path, the null file would be saved wherever the program is. Including that path just makes the null file save in the system temp directory, which makes it nicer for the user because they don't have to clean up after the program. ping localhost -n 2 > C:\WINDOWS\Temp\null echo . echo E-BOOK PORTAL echo ......................... REM Ok: this stuff is the viewable-by-user part of the menu. Including a "go back to main menu" option just makes things more user friendly. echo 1 - Complete Shakespeare echo 2 - Main Menu REM and here you set the variable. NOTE that this is the same variable you set before, but if you don't specify that you want to add this next value to the previous value, it will just replace whatever was stored there before. set /p port= Your Portal: REM OK: here is where you have the websites listed. And wait....ITS REALLY EASY! After the "if ____" command, all you have to do is say "start yourwebsite.com" and when that option is selected, the website will automatically pop open in the user's default web browser. Cool, huh? if %port% EQU 1 start http://shakespeare.mit.edu/works.html if %port% EQU 2 goto :mainmenu if %port% GEQ 3 goto :error REM this "goto :launched" thing below just tells the program to skip to the :launched label, a label which says "this website was launched..." In other words, a success message. goto :launched
And there you go - the basics of making the menus and the portal sections.
So now you know how to do the separate parts, lets try putting the whole thing together. Here is a sample portal that I have created. Don't just copy and paste it, see how it combines the menus and the website launching and makes it into a comprehensive user-friendly web portal!
@echo off title VD Web Portal V1.0 echo Welcome to the VD Web Portal! ping localhost -n 2 > C:\WINDOWS\Temp\null goto :mainmenu :mainmenu echo . echo MAIN MENU echo ......................... echo 1 - History Portal echo 2 - E-Book Portal echo 3 - LOTR Portal echo 4 - About echo 5 - Exit Program set /p port= Your Portal: if %port% EQU 1 goto :historyport if %port% EQU 2 goto :ebookport if %port% EQU 3 goto :lotrport if %port% EQU 4 goto :about if %port% EQU 5 goto :exit if %port% GEQ 6 goto :error goto :error :historyport ping localhost -n 2 > C:\WINDOWS\Temp\null echo . echo HISTORY PORTAL echo ......................... echo 1 - EuroDocs echo 2 - Labrynth echo 3 - Internet Modern Sourcebook echo 4 - Internet Medieval Sourcebook echo 5 - Internet Ancient Sourcebook echo 6 - bp11700 echo 7 - Tudor History echo 8 - Tudor England echo 9 - Luminarium echo 10 - A.P. European History echo 11 - Ancient Scripts echo 12 - World Civilizations echo 13 - Traveler's Accounts echo 14 - Main Menu set /p port= Your Portal: if %port% EQU 1 start http://eudocs.lib.byu.edu/index.php/Main_Page if %port% EQU 2 start http://labyrinth.georgetown.edu/ if %port% EQU 3 start http://www.fordham.edu/halsall/mod/modsbook.html if %port% EQU 4 start http://www.fordham.edu/halsall/sbook.html if %port% EQU 5 start http://www.fordham.edu/halsall/ancient/asbook.html if %port% EQU 6 start http://www.bpi1700.org.uk/index.html if %port% EQU 7 start http://tudorhistory.org/ if %port% EQU 8 start http://englishhistory.net/tudor.html if %port% EQU 9 start http://www.luminarium.org/ if %port% EQU 10 start http://www.historyteacher.net/APEuroCourse/APEuro_Main_Weblinks_Page.htm if %port% EQU 11 start http://www.ancientscripts.com/ if %port% EQU 12 start http://www.wwnorton.com/college/history/ralph/access.htm if %port% EQU 13 start http://www.fordham.edu/halsall/IHSP-travelers.html if %port% EQU 14 goto :mainmenu if %port% GEQ 15 goto :error goto :launched :ebookport ping localhost -n 2 > C:\WINDOWS\Temp\null echo . echo E-BOOK PORTAL echo ......................... echo 1 - Complete Shakespeare echo 2 - Main Menu set /p port= Your Portal: if %port% EQU 1 start http://shakespeare.mit.edu/works.html if %port% EQU 2 goto :mainmenu if %port% GEQ 3 goto :error goto :launched :lotrport ping localhost -n 2 > C:\WINDOWS\Temp\null echo . echo LOTR PORTAL echo ......................... echo 1 - Arwen-Undomiel echo 2 - Hisweloke Sindarin Dictionary echo 3 - Nevrast echo 4 - Council of Elrond echo 5 - Forodrim echo 6 - Ostatni Przyjazny Dom echo 7 - Elvish Linguistic Fellowship echo 8 - Ardalambion echo 9 - The Book of Silver Leaves echo 10 - Glaemscrafu echo 11 - National Geographic Lord of the Rings echo 12 - Encyclopedia of Arda echo 13 - Tolkien Bibliography echo 14 - Main Menu set /p port= Your Portal: if %port% EQU 1 start http://www.arwen-undomiel.com/index.html if %port% EQU 2 start http://www.jrrvf.com/hisweloke/sindar/online/sindar/dict-sd-en.html if %port% EQU 3 start http://www.nevrast.net/dictionary.html if %port% EQU 4 start http://www.councilofelrond.com/index.php if %port% EQU 5 start http://www.forodrim.org/ if %port% EQU 6 start http://www.tolkien.cyberdusk.pl/index.php if %port% EQU 7 start http://www.elvish.org/ if %port% EQU 8 start http://folk.uib.no/hnohf/ if %port% EQU 9 start http://www.phy.duke.edu/~trenk/elvish/ if %port% EQU 10 start http://www.jrrvf.com/~glaemscrafu/texts/index-a.htm if %port% EQU 11 start http://www.nationalgeographic.com/ngbeyond/rings/language.html if %port% EQU 12 start http://www.glyphweb.com/ARDA/ if %port% EQU 13 start http://www.tolkienbooks.net/html/languages.htm if %port% EQU 14 goto :mainmenu if %port% GEQ 15 goto :error goto :launched :about ping localhost -n 2 > C:\WINDOWS\Temp\null echo . echo ABOUT echo ......................... echo This program is a Web Portal to a variety of sites on the internet. It was designed by VulcanDesign, and is available for free to the public. Copyright (c) 2009 by VulcanDesign, all rights reserved. This program is Freeware, and is available for public distribution. This program is only usable for non-commercial purposes. Please do not modify this program in any way. If you do get special permission to modify this program (attainable by emailing VulcanDesign@Ymail.com), please keep this ABOUT section in the program. echo Return to the Main Menu pause> C:\WINDOWS\Temp\null goto :mainmenu :error ping localhost -n 2 > C:\WINDOWS\Temp\null echo Sorry, thats not one of the available options. echo Returning to Main Menu ping localhost -n 1> null goto :mainmenu :launched echo . echo Your website was succesfully launched! set /p relaunch= Would you like to launch another website? (Y/N): if /i %relaunch% EQU Y goto :mainmenu if /i %relaunch% EQU N goto :exit :exit echo Thank you for for using VD Web Portal! ping localhost -n 2 > null :eof
Hope that helped!