At the request of FrostBloom, I am creating a thread to teach the standard syntax of windows batch code. Please not that this is NOT a programming language, but a simple shell manipulation code recognized by windows operating systems.
I will not cover the ENTIRE syntax of the Windows Shell, simply those that are most useful in writing scripts
<Syntax>
@: This will hide a command, best used if you don't want to disable "Echo"
Usage: @"CMAND" (This will force the interpreter to hide the command used)
-
Echo: Used for manipulating local text output.
Usage: Echo TEST Output: TEST
Notes: When used like so, "Echo Off", will Disable ALL background code, Useful for making it look a LOT cleaner upon running the script. It will hide your directory, auto input, and commands. Also, if used as "Echo.", It will force a line to skip.
-
Set: This will set a Variable for local usage inside the batch script, careful not to use any Environmental Variables or system used ones, else you may mess up your machine.
Usage: Set TEST=LONG_ASS_STRING_OF_CODE Output: Use your Brain
-
%%: This works like a Variable quoting system, when defining a variable. To use that variable you must put it inside these symbols.
Usage: Echo TEST Outpust: TEST
(Proper)Usage: echo %TEST% Output: "LONG_ASS_CODE_YOU_USED_EARLIER"
-
Set /p 'var'=: This will force the user to input Text into the console for feedback.
Usage: Set /p cmd=<User_Input> Output: Whatever is returned will give result
-
If: When used to retrieve result from the Set command will give a follow-up command.
Basically an Option system.
Usage: If '%cmd%'=='<Whatever the user entered>' COMMAND
Notes: When used with the declared variable, this allows the user to define the local variable with input. Commands can be added before or after when used with '%%' to define the variable. (Example: Echo %cmd% is my name)
-
goto: This will go to specific portions of the script
Usage: Goto :Main Output: will carry out the script beneath ":Main"
-
":label" : This uses a Label system so that you can create a script with a script.
Usage: :Main Output: ":Main" Exists
-
cls: Clears Screen
Pause: Pauses
</Syntax>
<Example>
@Echo off
cls
Echo Hello, What is your Name?
echo.
Set /p cmd=My name is
cls
echo My Name Is %cmd% And I am an EOServ Member.
echo.
pause
cls
echo Are you Gay?
echo.
Set /p cmd= Y/N -
if '%cmd%'=='y' goto :yes
if '%cmd%'=='n' goto :no
:yes
cls
echo YOU ARE GAY
echo.
pause
exit
:no
cls
echo YOU ARE NOT GAY
echo.
pause
exit
</Example>
Any Questions? Add me on MSN_Live. Remember, this is a SMALL syntax Guide, it is suggested you either seek an online guide or allow me to directly teach you via MSN.