MS-DOS – How-to – Use batch files to create a working environment

Have you ever noticed that when you get started on a particular task on your computer, you always open up the same bundle of programs to do it? Why not make it easier for yourself and get all of these programs loading up when you want them, with a single click. The answer is batch files.

Batch files have been around longer than Windows has, but sadly they have been forgotten over the years. Generally, DOS is not a nice environment to work in compared to the graphical operating systems we have these days. I feel batch files still have their place. They are very simple to create and they can be edited easily.

You may have already set up your computer to automatically launch particular programs as part of your computers start up sequence. While this will work, it is not really the ideal situation, because you may not be ready to use the programs straight away. This can slightly slow you down or clutter your workspace, for no good reason. Instead, if you use batch files, your specified programs will launch simultaneously with one click, only when you’re ready to use them.

In this article we will look at how to create some basic batch files which you can alter to suit your own needs. For this How-to article, I am going to use batch files to launch environments, e.g. turning your computer into a multimedia heaven.

When I first thought about this article, I was thinking of a particular scenario I suffer with. I am sure there are a number of similar scenarios where a batch file can help. Take note of excessive clicking and ask yourself if you could automate the clicks by creating your own batch file.

Batch files will help to free up the machines power to launch programs. Computers have the power to load up multiple programs in the same time it takes you to get through the start menu, and click on one of the programs you want. With batch files, you can be up and running within seconds instead of a few minutes.

If you like where this article is heading, create a folder somewhere on your computer to put your batch files into, as you will probably make a few of them. Batch files won’t allow for the icon to be changed, so we need to make shortcuts to them, and then you can change the icon of the shortcut.

Open up Notepad and click “Save As”. You can name the file anything you want, but ensure you change the view to “all files”, and put a .bat on end of the file, e.g. multimedia.bat 

A few examples of what a batch file can do:

[tab:Programs]

Load up a Program

We can use a batch file to load up any application or utility we might need to do a set task.

The command line to open up Winamp from the command line is:

Start "" "C:/Program Files/Winamp/winamp.exe"

You can find the path of most programs by navigating through the start menu to the program you want, right click and select properties. In the dialog that opens up, you should find the path and executable you will need to enter into the batch file.

The hardest thing to remember is the placement of the speech marks.

[tab:Documents]

Load up documents

We are not limited to launching only programs. We can extend batch files to open up documents. This could be useful in all sorts of scenarios. For some people, they work on a particular Excel spreadsheet each day or they want their time-sheet when they get into the office.

This can normally be done by navigating to the folder of the document and then launching the document itself. Windows will look after which program it should open up in as the batch file will use the same defaults that have been built into Windows. The code to do this is below.

Start "" "C:/Documents and Settings/Username/My Documents/document.doc"

This should work for most programs, but if it doesn’t work for you, you may need to launch the program followed by the filename and path. e.g. on a single line, with no text wrapping.

Start "" "C:/Program Files/Microsoft Office/Office12/winword.exe" C:/Documents and Settings.. etc

The first option is desirable as it is quicker.

[tab:Websites]

Load up Websites

As well as launching programs and documents, we are able to launch our [gs browser] with a particular website. This could be handy if you want to load a TV guide from a website along with TV viewing software.

The command to make this happen is as below:

Start "" "C:/Program Files/Internet Explorer/iexplore.exe" http://www.inspectmygadget.com

[tab:Environment]

Load up an Environment

We can bring together what we have learnt to make a batch file that will load up all the necessary applications and utilities we might need to perform a set task. You can use this to set up an excellent working environment.

If you want to launch multiple programs at once, repeat the above example for each program, document or website, e.g.

Start "" "C:/Program Files/Winamp/winamp.exe" Start "" "C:/Program Files/TechSmith/SnagIt 8/SnagIt32.exe" Start "" "C:/Program Files/Microsoft Office/Office12/winword.exe"

This [gs batch file] will launch Winamp, SnagIt and MS Word all at the same time.

[tab:Example 1]

Some other examples

As everyones needs are different, I don’t want the above examples to be used as “The right way”. Each person needs to examine what will work best for them. Below are some combinations of what is possible to help you come up with a solution that may be right for you.

Keep in mind that batch files are extremely easy to edit, so if it isn’t working for you one way, it is easy to add, remove or edit any line you have previously put into the batch file.

  • Web Designer – Notepad, Flash, Cold fusion etc.
  • Blogger – SnagIt, BlogJet, Ideas Document and a music player;
  • Gamer – Resolution changer, Game, controller software and volume utility;
  • Government worker – Solitaire, Hearts, Miniclip, YouTube

Some of these examples are more practical than others, but you get the drift.

[tab:Example 2]

A more complex example

The command to launch multiple programs one after another rather than simultaneously, is slightly different to the example above. We need to remove the “start” command so that they don’t launch all at once. This will stop each new line of the batch file loading up automatically. Instead, each step will need to be closed before the next command line can be executed.

When I send my computers video signal over to my TV, I need to drop the resolution, open up Windows Media Center, and when I am finished with Media Center, I need to set the resolution back to it’s original state. The navigation of menus and multiple clicks can instead be reduced to a single execution.

In this example, I am using a utility called ResChange to change my [gs resolution]. The utility is completely controlled by the command line, so it is ideal for batch files.

Below is the code I used to make it all happen.

C:/ResChange/reschange.exe -width=640 -height=480 -refresh=60 %SystemRoot%/ehome/ehshell.exe C:/Reschange/reschange.exe -width=1280 -height=1024 -refresh=max

The first line drops the resolution to 640×480
The second line launches Windows Media Center
The third line changes the resolution back to my Windows default.

I could not use compatibility mode to do this because I also needed to change the refresh rate.

This sequential type of batch file is ideal for a task that requires multiple programs, one after the other; e.g. Ripping a CD, you might rip the music off the CD in one program, convert the file to MP3 in another and then finally edit the tags in a third program. A [gs batch file] like this can be used to automatically launch the next step in the process.

There are hundreds of little utilities that we can use to improve our computing experience. Using them around our main programs, means that we don’t need to go through the hassles of manually loading them up.

[tab:Extras]

Extras

When loading up an environment where you may occasionally want to load an additional program, you are able to add questions into the [gs batch file]. e.g. If you want to load up load up a web [gs browser] and email program every time, and sometimes word as well. You can make the batch file open up the web browser and email automatically, and then prompt you to say yes or no to opening up word.

While that sounds nice, it is not really very helpful as it is quicker to load up word with mouse clicks instead of the example shown above. I thought I should mention it in case you wanted to experiment with such features.

We want to use batch files to speed us up and not slow us down, so I won’t go into how you can do this here.

[tab:Problems]

Problems

Batch files are not very smart. They do what they are told and they are only really able to execute commands. If you want to use batch files to load up environments, take note that you cannot use batch files to unload environments. Each program will need to be manually closed down individually (or closed at shutdown).

This is only really an issue if you want to use this method to load up a range of different environments. If you have two environments that launch your web browser, you will end up with two browsers open. While this is not a big issue, it could become frustrating over time and is worth mentioning.

[tab:END]

SOURCE

LINK (Inspectmygadget.com)

LANGUAGE
ENGLISH