Link to home
Create AccountLog in
Avatar of John_Long

asked on

Cannot run batch file

We cannot get a .bat file to run on a user's workstation. When you double click on the shortcut, the command window opens up and shows the path where the batch file is located. If you enter the name of the batch file, it will run. However, it should not require thie extra step.
Avatar of mincftw

Under the script place a sentence pause and run the script again.

It shows you what happens while running the script.
Avatar of Paul MacDonald
Are you sure it's not running, then quitting?  

Also (and more likely) is the shortcut correct?  That is, are you sure the shortcut doesn't just point to the folder?  Does the path have spaces in it?  Is the path wrapped in quotes?
It sound like the filetype association for opening & executing a .BAT file has changed from the defaults.

For a really quick fix,  check out this site:
XP File Association Fixes

Download the .BAT fix and run the registry file.

or you can do it manually by

Guide to this Key:
Make sure the value is as below:
command = \"%1\" %*

If the % is missing, then it will open the Command Windows to the path Only.

The full reg file is enclosed for your convenience.
Create a notepad file save it as batfix.reg
double click it, answer yes to add to registry.

Windows Registry Editor Version 5.00



@="MS-DOS Batch File"






@="\"%1\" %*"







[HKEY_CLASSES_ROOT\batfile\shellex\PropertySheetHandlers\ShimLayer Property Page]

Open in new window

Avatar of John_Long


The test batch file has only 2 lines in it.
echo "This is a test"

We created the shortcut by right clicking on the batch and selecting "send to desktop create shortcut"
This batch file and other batch files that we actually want to use run properly on other workstations.
The shortcut creation just points to the batch file.  

For test purposes, have you created and tested any other batch files on this workstation?
Do you receive the same result?

If you receive the same result, then I suggest running the repair I've listed above, then the workstation will be able to run bat files.

I am receiving the same result with all batch files we are trying to run on this workstation.

I have checked the registry and have found the command line  as you have listed. I have checked against other worksations where the batch file works properly and found the command line to be the same. The only difference is that you have shown it as \"%1\" %* whereas the other registries show it as "%1" %*  That is without the slashes. I have tried it both ways and neither has made a difference.
Have you tried renaming the .bat files to .cmd files?
Hi.. try this

Download and Run the BAT File Association fix

Good luck!
Never mind... they already sent you that link
is the batch file located on the local computer or on the network.
We have tried running .cmd files no difference.  We have tried the batch file from the local machine and from the network.
What happens if you place the batch file on the desktop?
Do you have any realtime antivirus such as Symantec Endpoint Security or group policies applied to the user or specific machine which could be preventing the execution of a cmd file?

Has this computer been previously infected with malware or a virus?
No group policies that are applied to just this user or machine. We do run Symantec EndPoint Protection on this workstation and all the workstations in our domain. They all have the same setup. We also run Spybot on this workstation but, we run it on many other workstations. We have had malware and viruses on this workstation before but we have cleaned them up.

Try the following:

From a command prompt type the following command;
assoc .bat
should return with
If not
assoc .bat=batfile
to restore the default file type association.

ftype batfile
should return with
batfile="%1" %*
If not
ftype batfile="%1" %*
to restore the default "Open" action for the file type.

Avatar of FirstSentinel
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account