# batch files not running correctly



## Mister Fox (Feb 5, 2012)

Whenever I try to run a batch file (double click, click and Enter, right click and Open), a command prompt comes up that shows the location of the batch file on my computer. The file doesn't actually run. If I take the file and drag it into the command prompt it will open, but this is inconvenient. 
Does anyone know how to fix this?


----------



## shawnpb (May 30, 2010)

What is the batch file contain? What is the code? Post here please.


----------



## Mister Fox (Feb 5, 2012)

This happens with any batch file, it doesn't matter what the code is- this happens with empty batch files too. Also, batch files have a different symbol on my computer. 
Here's an example of what it all looks like


----------



## shawnpb (May 30, 2010)

does the batch file have a file name and a .bat? For example something.bat?

The icon I see on your desktop does not look like a batch file it looks like a cmd file.

Rename the file with a .bat then try to open it.


----------



## Mister Fox (Feb 5, 2012)

The file in the picture is named Example.bat
However, when I named the file Example.cmd, the batch symbol showed up and it worked perfectly!
That sorta solved my problem, but is there any way you know of to fix the .bat thing? It used to work, but then I selected a batch file one time and hit Open With and selected the command prompt as the default program (since it opened with that already I thought it wouldnt change anything...)


----------



## shawnpb (May 30, 2010)

Right click on the file locate "open With" and change it to a batch file or .bat

If you edit the batch file Right click on the file and select "Edit" Put
@ECHO OFF as the first line. then click on "File" then select "Save"

Command prompt will not open when you open the batch file I believe but I might be wrong.


----------



## Veegertx (Dec 31, 2011)

Mister Fox
you are running Win 7 and .cmd is the thing now. although some bats still run they have to be coded correctly, IE syntax


----------



## Mister Fox (Feb 5, 2012)

I've been coding for a while in batch so I know how they work. I'm just not sure why the files stopped working correctly. And FYI JackBauer, @echo off stops the command prompt from showing in text the commands given to it.
Thanks anyway, I converted all my .bat files to .cmd and they run perfectly.


----------



## jenae (Jun 17, 2008)

Hi, you might have some difficulty down the track so I would change to defaults, should be a .bat file with the right Icon. Run the attached .zip file and double click on the returned .reg file agree to add to registry, this returns to defaults. However always do a restore before modifying the reg. Restart computer.

View attachment Bat.zip


----------



## Mister Fox (Feb 5, 2012)

Thanks a lot jenae, that was what I was looking for.


----------

