Join us on our TWC Discord channel

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch file & Command Prompt introduction [Basics]
#1
What's going on guys? Here you have a simple tutorial which I explain what a batch file is, how to make one and the command prompt. If you follow each of these steps it shouldn't be a prob! This tutorial is simply an introduction to it. If these stuff seems interesting to you, I recommend you to read and follow it. Now if you are fluent in 6 different script you can read this just for fun. Biggrin
Note: if you're stuck on something, PM me.



What's a ''batch'' file?

- A batch file is a type of script file; a text file containing commands that get executed by the command prompt. What the command prompt basically is, is a thing on windows that can control your whole system. (If you're administrator.) But there have been discovered ''tricks'' a long time ago to open the CMD (stands for Command Prompt) as administrator. With this you can make (big) changes in the PC, as changed the admin's password.

[Image: 10zmf4p.jpg]

You don't download a batch file, you'll discover how to make one simply by using notepad.



How to make a batch file?
- If you want to make a batch file, simply open notepad, then save the name as [sample].bat and select save as all files as shown on the SS.

[Image: awao2g.jpg]

Now, when you open it, it does nothing! Why? Because we didn't put any commands in the file. I'll go through a list of command and make the CMD tell you ''Hi!'' First, right click on your file where you saved it and click on edit. Now follow the next steps carefully:

- @echo off = What this does, is keeping the commands hidden that you have written and only show what the commands do. (Like when you do !ban player in wolfenstein, it doesn't show the command but only what it executes) You always start a batch file with this line.

- echo [text] = Makes a text appear in CMD.

- echo. = Leaves a blank line to appear in CMD.

- pause = Pauses the CMD, withouth this the CMD would appear for like 0.2 seconds where it executes the given commands and closes right after. If you want the user to be able to see what happens, use this.

- cls = Clears the screen. (We don't have to use it now)

- title [title] = Uses this as the CMD's screen's title. (I added this after the SS, but it's simply to use. Put it right under @echo off and then continue)

When your done with your scripting just hit save.

Let's see how this looks like on a notepad and on the CMD:
(I couldn't show it any clearer)

[Image: 30jqpza.jpg]

As you can see, it works. Now you might wonder what that Dutch line says, it means ''Strike any key to continue'' thanks to our pause command. After you strike a key, it'll go to the next command. Which in now case is, nothing.


Command Prompt
- The command prompt is certainly not a toy, its something which in you can control your system in, like I said in the intro. With this could be done many and many things, I could go on and on but I'll show you a little bit of the easiest. Note: Don't play with this if you don't know what you're doing!
(You can find all commands here > All CMD Commands <

- ping [website.host] = Here in you can find the ip adress of a website.
What it actually does, it tests a network connection - if successful, ping returns the ip address. With an ip, you can connect to the website through using just the combination of numbers of the ip adress.

- cls = Clears the screen.

- shutdown -i = Opens the shutdown window, you select the computer and then you can set further information like notify user, wait 30 seconds etc.

- tree = A display of your folder structure.

- color [code] = sets the CMD screen to the colors you said him to use. Here are all codes (You can combi)

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

- MSG username [options] [message] = Send a pop-up message to users on your computer.


Sooo this was a small introdution to batch files and the command prompt. I hope I learned you a bit now and that your experiment worked. (If you made one)
Now don't forget that this isn't everything, there are sooo much codes you can use with batch and these are only one of the most simple ones.
Thanks for your interest and time, good luck!
(If I have time tomorrow I'll make a second tut with more about batch programming.)

Take care bro's and sisters!
Regards.
[Image: rtrmkeG.png]

[Image: hGVkXBM.png]
Reply
#2
This only shows you how to print out text and change its colors, pause and stuff. Next, if you want you could show how to run commands and make little utilities, very simple ones.
Example, how to fast find/run file with: for /f "delims=" %%i in ('dir /b /a-d /s c:\yourfileatcdrive.txt') do "%%~fi"
or copy paste files: for /f "delims=" %%i in ('dir /s /b /a-d c:\yourfileatcdrive.txt') do copy /b "%%~i" "C:\P
And how to jump lines, make options or "IF" lines. After those you can make something worth of it out of them, something that makes things easier.
Ofc this is good start, but if you are interested you can continue to making little scripts out of them. Batch is not kinda official programming language, I would recommend to start with C or HTML, as others told so too, and they are more likely needed out there.
[Image: 5zpsna.jpg]
Live today like it is your last day!
...but pay your bills and use condom just in case it isn't.

Sniper 12.5.2012 - 19.7.2013
Thank you for great Member/Supreme time!
Reply
#3
I know those too. But i thought let me include that into the more advanced tut later on. Wink
[Image: rtrmkeG.png]

[Image: hGVkXBM.png]
Reply
#4
Can you give me some examples where I could use this for?
[Image: 4619468.png]
[Image: 2r5gv21.gif]
Reply
#5
to run Wolfenstein in high priority mode use a shortcut with
Code:
C:\Windows\System32\cmd.exe /c start "runhigh" /high "C:\Program Files\Wolfenstein - Enemy Territory\ET.exe" +pb_sleep 500 +exec autoexec.cfg
as destination
you can also add
Code:
+connect nd.twcclan.org
at the end of the code to automatically connect to nd (or whatever server you want)
[Image: dlnof9.jpg]
Reply
#6
(14-11-2013, 06:45 PM)djuki Wrote: Can you give me some examples where I could use this for?

Well, you can control your whole system within one file.
So lets say you want to delete temporary files within one click, you can make that into a Batch file.
(Run it as admin)

Code:
@echo off del /s /f /q c:\windows\temp\*.* rd /s /q c:\windows\temp md c:\windows\temp del /s /f /q C:\WINDOWS\Prefetch del /s /f /q %temp%\*.* rd /s /q %temp% md %temp% deltree /y c:\windows\tempor~1 deltree /y c:\windows\temp deltree /y c:\windows\tmp deltree /y c:\windows\ff*.tmp deltree /y c:\windows\history deltree /y c:\windows\cookies deltree /y c:\windows\recent deltree /y c:\windows\spool\printers del c:\WIN386.SWP cls

As it says it just deletes unnecessary files.

This is one example. I just can't explain what it's really used for in one sentence. I hope some examples will make you understand.

With batch programming, you can do things you wouldn't be able to by yourself. Like opening cmd as admin, deleting/renaming/replacing files at once. There is much more that I can't call up at the moment.
Hope this helped you out. If not, my apologizes, but watch for my second tutorial which I'll discuss more things you can do to give you a better sight on batch programming. Thanks for your time!

Kind regards.

(14-11-2013, 07:44 PM)a TEAMMATE Wrote: to run Wolfenstein in high priority mode use a shortcut with
Code:
C:\Windows\System32\cmd.exe /c start "runhigh" /high "C:\Program Files\Wolfenstein - Enemy Territory\ET.exe" +pb_sleep 500 +exec autoexec.cfg
as destination
you can also add
Code:
+connect nd.twcclan.org
at the end of the code to automatically connect to nd (or whatever server you want)

Nice ones, I sure might try out the first one. Smile
Thanks for sharing!

Regards.
[Image: rtrmkeG.png]

[Image: hGVkXBM.png]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cant remember command? Haures 1 2,676 30-08-2016, 12:44 AM
Last Post: HamsteR!
  Tekkit: Introduction Bread 10 6,327 16-04-2013, 08:48 AM
Last Post: ThaKilla
  Basics of Trickjumping Teleport 0 3,172 21-10-2012, 08:40 AM
Last Post: Teleport
  Command and Cvar list + Console Commands Chucky 5 16,898 20-08-2012, 07:53 PM
Last Post: Chucky

Forum Jump:


Users browsing this thread: