Learn to Code via Tutorials on Repl.it!

← Back to all posts
Windows CMD tutorial - batch
EpicGamer007 (1535)

Windows CMD tutorial

Use the windows command prompt to your advantage!

Hey everyone! I was exploring some stuff about Windows and hacking cause I just wanted to learn about it. I found a lot of tutorials about how you can use cmd to do cool things!

So basic overview first:

What is the command prompt?

The command prompt is a command line interpreter.
It is available in most Windows PC's and laptops

It is used to execute Commands(hence the name). These commands are used to perform certain functions on the computer, usually for administrative purposes and troubleshooting problems.

It can also run .bat files. .bat is the file extension for batch files.

Basic commands

Now I will go over basic commands at the prompt.

CD - cd {path}

Using this command, you can navigate you command to {path}. For you, that could be C:\Users\{Your user}\Desktop or C\Windows

Title - title {title}

Using this command, you can change the title of the command prompt. By default, it is set to Command Prompt. But if you do not like that, you can change it to something like WINDOWS IS NOT GARBAGE or why no bash.

Prompt - prompt {prompt}

Your prompt is set by default to the current folder you are in. But what if you do not want the prompt to be a folder? Simple, change the prompt by doing prompt {prompt}.

There are also special things you can do in it. If you still want the directory you are in but just want to add some more, you can do that! Here is a list of what you can add:

$t - Changes the prompt to the current time
$d - Changes the prompt to the current date
$p - Changes the prompt to current directory
$g - Changes the prompt to >
$g - Adds a "enter"

So for example you could do:
prompt I am the best in the world and the directory I am in is $p$g which will result in
I am the best in the world and the directory I am in is {Current Directory}>

What I like to do is prompt $t $d - $p$g to get the prompt {current time} {current date} - {durrent directory}>

History - doskey /history

Prints all commands you have preiviously used

Make Directory - mkdir {folder name}

Creates a folder with the name {folder name} in the current directory

If your folder name contains whitespace, surround it with "" so it would be mkdir "folder which has whitespace in name"

Tree - tree {args}

The tree command lists out every folder in the current directory.

But what if you want files? Simple! add /f to the end to make it tree /f.

But oh no another problem, looking at the tree is a pain at the cmd prompt. Well another fix! add > "C:\Users\{You user}\Desktop\ouput.txt" to make tree /f > "C:\Users\{You user}\Desktop\ouput.txt".
Now your tree will be printed in output.txt and it will be much easier to check it out there.

Tracert - tracert {website or ip}

The tracert command can be used to get the path from your PC to a website or ip.

https://static1.makeuseofimages.com/wp-content/uploads/2018/11/tracertcmd.png?q=50&fit=crop&w=750&dpr=1.5

It is a complex command to use I found this tutorial which may be able to help you with some parts.

Systeminfo - systeminfo

This prints out information about the current PC. It's name, it's OS name, it's system manufacturer, etc.

Shutdown - shutdown

In my opinion, this is a really cool one.

The shutdown command can be used to do much more than shutdown your computer. The shutdown command by itself will not do anything, you need to provide arguments to specify what to do:

The following images is from this link.

Doing shutdown /i will open up a GUI which you can then use to shut down pretty much any computer in your domain. Of course, do not use this unless you have permission.

shutdown /l will log the user out of the computer, not shut it down.

shutdown /r will restart the users computer

shutdown /? will print out all the shutdown command args

Pause - pause

All this does is ask the user to press enter before continuing

Batch files = .bat

You can also create batch files, kind of like a .sh file, when you click on it or run it, it will do whatever is in the batch file

Just put some commands ina file and it should work.

End

That is all for this folks, I do know that the majoriy of people use Wandows so I made this tutorial.

If there are any commands I left out, tell me in the comments

FOR ALL YOU WINDOWS HATERS OUT THERE, IF YOU WANT ME TO MAKE A BASH TUTORIAL. TELL ME.

I know repl uses bash so I am already planning on doing it

Also, I might add stuff to this if it gets support(upvotes and comments)

See you next time!

Comments
hotnewtop
EnriqueAvila2 (0)

Pretty good! Looking forward for the next one

Highwayman (1459)

I just made my first encounter with the windows command line very recently, so this is very encouraging in a way to have this thank you so much!! 😜

EpicGamer007 (1535)

@Wumi4 , thanks! Hope you learned something