How to Create a Web-opener in Batch
Intro: How to Create a Web-opener in Batch
Before creating a web-opener lets go through a simple code tutorial..
1>(echo) code "echo" are used to write a text for e.g " echo Welcome to Instructables".
2>(color 30)code "color" are used to give color to background and font.
3>(set /p =)code "set /p" is used to create console in program.
4>(title)code "title" is used to give title to program
5>(start)code "start" is used to start a external file.
6>(pause)code "pause" is used to pause a program to avoid, crash.
Here's the code
<---------------------------------------------------------------------------------
@echo off
title Web opener
color 30
:main
echo.
echo Type url (www.example.com)
echo.
set /p url=www.
echo.
start http://www.%url%/
echo.
echo Web history: %url% was opened..
pause
cls
goto main
-------------------------------------------------------------------------------->
Explanation
1>The code "set /p url" is used to create a console in program and got value can be showed by "%url%".
2>When user types url and presses enter, then that value is forwarded to the code "start" and got value is showed by "%url%".
3> In the same way "echo Web history: %url% was opened.." can be showed..
Please leave a COMMENT..
1>(echo) code "echo" are used to write a text for e.g " echo Welcome to Instructables".
2>(color 30)code "color" are used to give color to background and font.
3>(set /p =)code "set /p" is used to create console in program.
4>(title)code "title" is used to give title to program
5>(start)code "start" is used to start a external file.
6>(pause)code "pause" is used to pause a program to avoid, crash.
Here's the code
<---------------------------------------------------------------------------------
@echo off
title Web opener
color 30
:main
echo.
echo Type url (www.example.com)
echo.
set /p url=www.
echo.
start http://www.%url%/
echo.
echo Web history: %url% was opened..
pause
cls
goto main
-------------------------------------------------------------------------------->
Explanation
1>The code "set /p url" is used to create a console in program and got value can be showed by "%url%".
2>When user types url and presses enter, then that value is forwarded to the code "start" and got value is showed by "%url%".
3> In the same way "echo Web history: %url% was opened.." can be showed..
Please leave a COMMENT..
STEP 1: Extraa
You can add the color codes..
this are some of color codes
Sets the default console foreground and background colors.
COLOR [attr]
attr Specifies color attribute of console output
Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground. Each digit
can be any of the following values:
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White
this are some of color codes
Sets the default console foreground and background colors.
COLOR [attr]
attr Specifies color attribute of console output
Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground. Each digit
can be any of the following values:
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White
3 Comments
Prof. Pickle 11 years ago
Firstly, you're sort of cheating the viewers here. You aren't creating CMD, you are simply starting it with a different title. Although clever, you should probably change your title.
Secondly, I am shocked by how much grammar and spelling mistakes I have found. Please proof-read your instructables beforehand.
Thirdly, this code, when run, will spam you with CMD windows and eventually cause your computer to crash. Please fix this with a pause or exit command.
Lastly, I hope this has not been too harsh as I would hate for it to ruin our friendship. Good luck on future projects.
code source 11 years ago
And you can comment on my posts frankly, From now I will try to improve my English..
And again thanks for your advice..
Prof. Pickle 11 years ago
Anyway, you have an error in your code. In the line "set /p url=" there is an error as you forgot the space between the "set" and the "/p".
Other than that I can't see anything that would phase anyone.
P.S. Ignore that comment below mine as I don't know how it got there.