Windows batch scripting basics in 2020

Hey, imagine that you open your computer’s shell. And then you write a command. Question: What happens? And what was maybe supposed to happen?

Computers are known to be quite fragile.

More than physically wearing out or actually “breaking” a computer, you’re likely to possibly mess things up a bit. Messing happens often by:

  • typo in command (a spell error)
  • running wrong command
  • running a command that was given by someone intentionally, in an attempt to fool you
  • running a bad command – that you saw on a web page

Don’t worry. Let’s supercharge you with knowledge on these commands and the shell!

use ‘which’ in cmd

Check what your command would do, beforehand.

With shell, we can always use where command

What is a computer shell?

A shell is just another program. It’s written to take in commands, and do stuff. Shells are convenient and powerful tools. They are operated by writing commands.

Shell scripts can in addition run anything that you can write interactively, plus scripts have a few extra powerful things:

  • IF statements (allows you to make logic)
  • loop structures (run thousands of things at once, fast)
  • variables (make complex things possible)

Try the shell commands

A command looks like this:

echo Hi!

Let’s try the “echo” command in an actual Windows shell.

In Windows, first open a shell:

  • press Alt+R
  • enter ‘cmd‘ in the box
  • press enter

Now you should see a rather black and dull looking shell window. Write, using keyboard, ‘echo Hi!’, and press Enter. So just write the text e,c,h,o and space and then capital H and i followed by exclamation character (Shift+1).

The shell says back Hi!

You have used an internal shell command on Windows. See you soon!

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: