Inspect My Gadget is here to help you realise the full potential
of your technologies, new and old, through detailed how-tos and
information about the latest software. This site has something
for everyone, from the beginner to the experienced geek.

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:

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.

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.

As well as launching programs and documents, we are able to launch our 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.

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.

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

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.

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

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 resolution. The utility is completely controlled by the command line, so it is ideal for batch files.

The first line drops the resolution to 640×480The second line launches Windows Media CenterThe 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 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.

Extras:

When loading up an environment where you may occasionally want to load an additional program, you are able to add questions into the batch file. e.g. If you want to load up load up a web 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.

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.

Conclusion:

I hope you have found this article helpful, and that you may have a use to bring batch files back from the dead. Batch files are not going to make your computing experience feel modern or high tech, but they have the potential to really speed up the loading of your applications. Please stick around and check out some other articles at Inspect My Gadget for more time-saving tips and tricks.

Dear Chris, thank you for your reply. I do not want to create a short cut on the desktop myself but rather I would like the batch file to do that for me.
For example, just as you would normally install a program, a desktop icon is created for the user; likewise I would like my batch file to do that.
Thank you.

AK, that’s getting a little trickier. You can use VB scripts and other complex things to make it happen, but I found it a bit too complicated.
Would this work… Keep the shortcut static, always pointing to the same file. Use the rename command in your batch file to rename the most current file to the file the shortcut is pointing to. As it renames a file, rename the old one back.
Either method is not easy.

Hi Marius, I am a bit confusd as to what you are asking. It is possible to call batch files from another batch file. There are programs like nirCMD that let you make shortcuts that will run multiple programs from a single shortcut. If you can explain what you would like to do more clearly, I can try to help more.

I have a folder of 1000 files that I need to convert to another file type (.fla to .swf). I found a .exe that will do this one file at a time. I’m wondering if there is a batch file I can create that will open a program (FLA2SWF.exe) and run it for every file in a specified folder?

I have a internal website that gives me access to a admin console. I can launch the site with a script but I need to be able to enter a password to get to it. The username always stays the same on the page. I’ve tried the suggestions here:
set /p password=%password%

I use a setup with DOSBox and a series of batch files for starting up old (DOS) versions of Microsoft Flight Simulator.

Since a few weeks I have a nasty problem. All the sudden the batch files stoppen running: they just open in Notepad instead. That is at the menu-option “Open”. And I can’t find a place where I can change this association of the .bat extenson. If I remember correctly there also used to be the option “Open with …” but I ca’t find that anymore.

I did find a work-around by creating a new user account and tried to start my batch file there. It does work, but then I have to re-create the whole background for this new user account, which I don’t intend to do.

Can anyone tell me what might be the reason for this unwanted coupling and how i can restore the old situation? Help would be very much appreciated.

You have an interesting problem. I haven’t experienced it myself, but maybe changing the extension to cmd instead of bat may work? IT should work the same way, you are just taking away any links that the bat extension may have developed.

So I can continue now, which is very good, but it would be even better if I would be able to break that association between batch files and Notepad.

One more remark about that: normally in Explorer, if you click on a file with the right mouse button, you get a pop-up menu with the option “Open” and a bit lower the option “Open with”. With the latter option you are able to change the standard association.

However, in the case of .bat files that second option is missing in the pop-up menu. Why??? Maybe this gives you an extra clue?

It occured to me… can you make sure that file extensions are shown. This can be done from explorer > tools > folder options > view. Maybe the file is really called file.bat.txt. This may be creating the association with notepad. If file extensions aren’t shown, it will appear as file.bat. A good indicator is the icon of the file.

The “open with” shouldn’t be shown for a bat file. Only open and edit. Windows sees a bat file as a program, rather than a document.

To change what program opens a file extension, this is also done in folder options. Bat files and cmd files are not listed though.

Thanks again, but that’s not the case I have “Hide file extensions for known file types” not chequed. Please forgive me if that’s not the exactly correct term, because I use a Dutch Windows version and have to try to translate the terms. So file extensions are all shown and it’s not: file.bat.txt.

BTW, the trick of changing .bat into .cmd works fully, so I can work in my normal user-account. Which makes things a lot easier. Thanks a millon. However it hurts me that normal .bat files still don’t work.

As you mention, there is (or in my case there was) a list of all file extension associations.The problem is that I can’t find that list any more. Although, if .bat and .cmd are not shown, it won’t help me with the .bat problem!?

Anyway I still would like to have accesss to that list, because a recent unintended installation of some odd audio/video player has hyjacked all my audio and video extensions.And finding them al to set back manually is virtually impossible. But where has the list gone? I remember vaguey a function under the main configuration screeen, but maybe that was under Windows XP?

So the status is: thanks to your advise I can work again, be it a bit crippled. But I really would like to find the real solution.

Hi Jos, I am glad that changing the extension worked. I am very confused as to why the open with option isn’t available. I have no idea how to bring it back. Probably a registry hack. The How-to geek website is full of good registry hacks that may bring it back.
To solve how your file associations are broken, I recently came across a program called Types which will help recreate those associations quickly. Check out this article for more information.
I hope you get some value out of my reply 😐

Hey Guys, I love this thread.
Lets make it move faster.
I love learning how to use batch files.
I am pretty experienced in them. Can someone give me some Experienced Examples?
in Vista
@echo off net user administrator activate:yes
anyways Be back everday to see who put something up for me and of course reply

Hi Justin, IE has a kiosk mode that will load the page in full screen.iexplore.exe -k http://www.inspectmygadget.com
Alt-tab will let you close it down.
You can create a shortcut in your startup menu. I hope this has been helpful.
Cheers

here’s a batch file. Name it the Martix.bat
@echo off
color 2
:start
echo %Random% %Random% %Random% %Random% %Random% %Random% %Random% %Random% %Random%
goto start
It does nothing that is worth it but it kills time and is fun