Hello peepz :D
In this small tutorial I'm gonna show you the basics of the oldskool Windows Batch / CMD.
Batch file extensions are:
.cmd = Mainly used for <Win2000
.bat = Mainly used for >Win2000
[1] - Start
First open up Notepad, we are going to start with the following command:
This code will remove the executable path and all executed commands.
This example show the message: Hi without @echo off and with @echo off.
[slide]http://img130.imageshack.us/img130/332/echooff.jpg[/slide]
To display a simple message we use the following command:
Always use the 'pause' command to pause the script.
Here are 2 examples of showing a simple message.
GOOD EXAMPLE:
WRONG EXAMPLE:
[2] - Batch Colors & Title
Now we are going to give your message script a attractive color.
The following code defines the BACKGROUND and TEXT color:
X = BACKGROUND COLOR
Y = TEXT COLOR
Color Table:
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
Example Script:
[slide]http://img541.imageshack.us/img541/8068/colort.jpg[/slide]
This command will give your batch window a title:
Put that command after @echo off or color.
[3] - Execute Commands
These are a few executing examples:
This script will start (execute) notepad.
or
Executing with command switches (This will import a reg file):
[4] - Making Menus
Now I'm gonna show you how to make a menu powered by user input.
The GOTO command will redirect to the tag "menu" (See example)
If you want to give the user choices you need this command:
If the user types 6 the script will execute the commands under the 'l0calh0st6' tag.
The
command will execute hidden pause. This will prevent the annoying text giving by the pause command.
[slide]http://img341.imageshack.us/img341/2791/choice.jpg[/slide]
[slide]http://img808.imageshack.us/img808/3447/note.jpg[/slide]
[5] - Usefull Commands
All batch commands can be found here:
http://www.robvanderwoude.com/batchcommands.php
cls - clears/cleans the current window.
ren - renames a file: ren input output.
pause>NULL - pause without text.
exit - close window.
[5] - Tools
Bat To Exe Converter
This tool converts .bat files to an executable .exe file.
You can give your exe a nice logo and version/company information.
http://download.cnet.com/Bat-To-Exe-Converter/3000-2069_4-10555897.html
Hidden Start
Run batch script silent without a window.
This can be embedded in registry and programming languages.
Usage:
IMPORTANT NOTE: IF YOUR BATCH FILE NEEDS TO EXECUTE COMMANDS WICH NEED ADMIN PRIVILEGES YOU NEED TO RUN THE BATCH FILE AS ADMIN. (Right click - Run as Admin.)
More Coming Soon! :D
In this small tutorial I'm gonna show you the basics of the oldskool Windows Batch / CMD.
Batch file extensions are:
.cmd = Mainly used for <Win2000
.bat = Mainly used for >Win2000
[1] - Start
First open up Notepad, we are going to start with the following command:
Code:
@echo off
This example show the message: Hi without @echo off and with @echo off.
[slide]http://img130.imageshack.us/img130/332/echooff.jpg[/slide]
To display a simple message we use the following command:
Code:
echo Hello World!
Here are 2 examples of showing a simple message.
GOOD EXAMPLE:
Code:
@echo off
echo I Love Wjunction!
pause
Code:
@echo off
echo I Love Wjunction!
Now we are going to give your message script a attractive color.
The following code defines the BACKGROUND and TEXT color:
Code:
color XY
Y = TEXT COLOR
Color Table:
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
Example Script:
Code:
@echo off
color 0c
This command will give your batch window a title:
Code:
title I Love Wjunction
[3] - Execute Commands
These are a few executing examples:
This script will start (execute) notepad.
Code:
@echo off
color 0c
start C:\Windows\notepad.exe
pause
Code:
@echo off
color 0c
C:\Windows\notepad.exe
pause
Code:
regedit /s wjunction.reg
Now I'm gonna show you how to make a menu powered by user input.
Code:
@echo off
title I Love Wjunction
color 0c
goto menu
Code:
:menu
echo I Love Wjunction & l0calh0st
pause
Code:
:choice
echo Choices: 1-7
set /P C=What do you want?:
if "%C%"=="1" goto l0calh0st1
if "%C%"=="2" goto l0calh0st2
if "%C%"=="3" goto l0calh0st3
if "%C%"=="4" goto l0calh0st4
if "%C%"=="5" goto l0calh0st5
if "%C%"=="6" goto l0calh0st6
if "%C%"=="7" goto l0calh0st7
pause>NULL
The
Code:
pause>NULL
[slide]http://img341.imageshack.us/img341/2791/choice.jpg[/slide]
[slide]http://img808.imageshack.us/img808/3447/note.jpg[/slide]
[5] - Usefull Commands
All batch commands can be found here:
http://www.robvanderwoude.com/batchcommands.php
cls - clears/cleans the current window.
ren - renames a file: ren input output.
pause>NULL - pause without text.
exit - close window.
[5] - Tools
Bat To Exe Converter
This tool converts .bat files to an executable .exe file.
You can give your exe a nice logo and version/company information.
http://download.cnet.com/Bat-To-Exe-Converter/3000-2069_4-10555897.html
Hidden Start
Run batch script silent without a window.
This can be embedded in registry and programming languages.
Usage:
Code:
hstart.exe /NOCONSOLE "mybatchfile.bat"
More Coming Soon! :D