In this section, I'll explain you important main commands for your batch file.Don't enter the quotationmarks in your file."@echo off" - Is always at the beginning of your file. This command blocks the output of your command in the cmd
"echo TEXT" - Here you enter "echo" and your text at the beginning of the line. This text appears in the cmd. E.g. : "echo Hello this is my first file"
"echo." - Will create a blank line
"pause" - Will create a pause in your file. The file continues by pressing any key. A message for that appears in the cmd
"pause>nul" - Has the same function like "pause" but you won't get the output in the cmd, that you need to press any key to continue
":TEXT" - Creates a certain section in your script
"goto TEXT" - This command brings you to the section "TEXT" in your code. "TEXT" can e.g. include any certain command, you want to execute
Declaration of variables:Now I'll show you, how to declare a variable"set test= Hello XDA-Members"
The variable "test" includes the string "Hello XDA-Members"
To access this variable, you need to enter %test%
"set /p input= Enter your variable:"
Here, the user needs to enter something in the cmd. This input will be saved in the variable "input".
To access this variable, you need to enter %input%
You can select the variable name as you want.
Now we have already some commands, so let's try them out.
In my example, I'll add comments to the commands, which are written in blue. Please don't add them to yours.
The second "@echo off" is not necessary

So, now we save the file and run it with a
double-click.
Your script should look like this:
(Not everything is in mine included)
Making a selection menu:Now, we make a selection meu where the user has several optionsStep by step:
- Create a list with "echo" commands
- Create an input variable
- Create an if statement
Let's take a look at my example code.
You should already understand the old commands. ;)

As you can see, this is still quite simple
If everything worked right, you should see this

Well, for the beginning that's enough. For the next step, you should
know all these commands and how they work. :)
0 commentaires:
Enregistrer un commentaire