Wednesday, May 22, 2013

Command prompt?

If any of you readers are old enough to know what DOS is, than you'll remember a screen that looks like this
For those of you who don't know. Before GUI or Graphics User Interface which allows you to have a "desktop" and to interact with the computer through a display, there was DOS, Disk Operating System. While DOS is pretty much useless now (and has been for a few years) Microsoft decided to carry parts of it over into their GUI system, through command prompt. Command prompt, as the name suggests, allows you to run commands from a terminal window. What a lot of people don't know, is that you don't need to be a programmer to use command prompt. In fact, you can use command prompt to automate a lot of the tasks you might already do on your computer.

  Command Prompt is also called a "command line interpreter". In English, that means that it will take what you type (as long as you type the correct commands) and translate it so your computer can use it. Also it means that your input will be in real time. Besides making your computer talk to you, you can use this to run commands or batches of commands. These commands can be anything from scheduling your computer to backup a certain folder at a certain time, to locking a folder for private viewing only, to just opening up several programs at once. You can run commands one at a time through the window, or if you want to run batches of commands, or make it an actual program with a shortcut, you can write a .bat file or batch file.

  A batch file is basically a collection of command's that are built together to make a program. For this example, I want to make a program that opens Oseeris.com and Photoshop at the same time. Oseeris.com is a stock photography site, that offers a lot of free, legal, high resolution images that can be used in Photoshop. The program is very simple. Here's how it will look, then I'll break apart each line and talk about it. Open up notepad on your computer to write the program. Then when you're finished, save it as website.bat
make sure to put .bat on the end, as this will tell the computer that it's an actual batch file and not just a text file.

@echo off
start iexplore.exe "http://oseeris.com/"
start photoshop.exe

  The first line "@echo off" basically tells the command prompt not to display a message on what your doing. While it doesn't really matter here, when you're repeating several hundred tasks or more at once, message's in the command window can slow the program to a halt.

  The second line "start iexplore.exe "http://oseeris.com/" " does two things. First it will start Internet explorer. The next part runs what's called an argument. An argument is something that you tell the program to do, once it's opened. In this case, I want internet explorer to load the webpage oseeris.com once it's opened. Arguments in command prompt usually come as quoted text after a certain command.

  Then the third line "start photoshop.exe" just simply starts up photoshop. In order to get a program like this to work on your computer, you'll have to look up the name of that program. In my case I had to go to the folder C:\Program File\Adobe\Photoshop CS6 to find the photoshop program. For this program, it was just called photoshop.exe, but sometimes it will be called something different, like iexplore.exe. Telling the program to run internet explorer, or internetexplorer.exe wouldn't have worked. All in all this is what your program should like in notepad



  Command Prompt is called a high level language, in that it's closer to the English language than some other code's, like java or C++. Command Prompt is a great and easy way for regular computer users to get tasks done faster, or for beginning programmers to learn the inter-workings of a terminal, and how code really works. If you're interested, here is a list to all the commands accepted by Command Prompt in Windows 7, and what the commands do
http://technet.microsoft.com/en-us/library/cc772390(v=ws.10).aspx

Thanks for reading this post, and please keep checking the blog, as we'll be posting more stuff like this all the time.

No comments:

Post a Comment