Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Can't run .bat files

20 Feb 2015   #1
Peter57r

windows 7 64
 
 
Can't run .bat files

I know a similar topic has come up before but the solutions aren't working for me.
I got to this site as a result of googling my problem and getting to here:

http://www.sevenforums.com/attachmen...eexecution.reg

I was in the situation where Windows7 would not recognise a .bat file at all (I would get 'file cannot be found' when right clicking on the bat file and selecting 'Open').

Having established that there was no file association for .bat I tried to fix it in the File Assocation manager by browsing to cmd.exe and selecting it.
This gave the appearance of being associated but still nothing worked.

Eventually I found the registry edit file above and tried to use that to fix the problem.

This got me a step further, in that double clicking a .bat file now opens the command processor, but the file still does not run. This might be because when running the .reg file I get messages that some keys cannot be imported because they are in use. However, I don't know how to get past this problem, because from my perspective I'm not running anything at the time. There are no apps running in task manager. I've tried running regedit in Safe mode but it produces the same messages.

I am Admin on my machine which is 64 bit Win7.

Just as background and not very relevant, this problem emerged when trying to set up an environment for an Android Studio course. Android studio appears to make lots of .bat calls to start up different features.
And of course none of them work for me. I can't change the calls that Android Studio is making. Lots of other people are using the same source material, apparently without this problem as no-one has any idea what I'm talking about.

The .bat calls are all very simple...and there are no spaces or odd characters in the path.
For example..
D:\androidsdk\build-tools\21.1.2\dx.bat

If anyone can suggest how I can complete the registry edit successfully, or has any other suggestions, I'd be grateful. I'm at a complete dead-end at the moment.

Regards

Peter


My System SpecsSystem Spec
.
20 Feb 2015   #2
RolandJS

Windows 7 Professional 64-bit
 
 

CTL-PNL --> Default Programs --> Set Associations, mine shows .bat associated with unknown application.
Registrar Registry Manager returns TMI. Trying W7Pro's regedit; Regedit's 1st .bat showing: .bat with PersistantHandler underneath; that's it; I guess the others hopefully can help you.
One program that might help: Tweaking.com's Windows Repair (All in One), download, install, run with defaults and add items 26 & 27; best run in Safe Mode w/Network; can be run in normal mode if your anti-viri/spy&mal-ware programs are off during the run.
My System SpecsSystem Spec
20 Feb 2015   #3
Randycool79

Windows 7 Ultimate x64/Windows xp Media center edition x64(Dual boot)/Windows10,Windows7,Ubuntu(64)
 
 

Try this... Open notepad. Then enter this following script and save as .reg file. But before you do this, go to regedit.exe, locate to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.BAT\UserChoice and delete the key user choice. Then copy this script and save as .reg file. Example bat.reg and open file. If that doesn't work open the .zip file. It will fix the .bat association file. Run the file and it will fix the .bat. If you get an error with using the .zip file, enter into safe mode and try running the file again. I personally think you should use Fixexec because it is not a pain in the butt!


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.bat]
@="batfile"

[HKEY_CLASSES_ROOT\.bat\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

[HKEY_CLASSES_ROOT\batfile\shell\open\command]
@="\"%1\" %*"


Attached Files
File Type: zip bat_fix_w7.zip (1.1 KB, 40 views)
File Type: zip Fixexec.zip (176.5 KB, 18 views)
My System SpecsSystem Spec
.

20 Feb 2015   #4
Brink

64-bit Windows 10 Pro
 
 

Hello Peter, and welcome to Seven Forums.

If you like, you could download and merge the .reg file for the listed bat option in the tutorial below. This will restore the default associations and registry entries for .bat files, and should fix this for you.

Default File Type Associations - Restore
My System SpecsSystem Spec
21 Feb 2015   #5
Peter57r

windows 7 64
 
 

Thanks to all who have replied above; I appreciate your efforts to help.
Clearly my problem is non-standard.
I'm afraid none of the suggested edits fix the issue. I'm back to the position of bat files not being recognised.
The attachment shows what I get when I right-click a bat file and choose Open, or I just double-click the .bat file.
I have looked at the reg edits that have been posted ( and tried them all) and I'm pretty sure that every key in the registry is set to the values indicated in the suggested .reg files. Even so the problem remains.
I have since discovered that if I rightclick a .bat file and 'Run As Administrator' the file runs. However, my research suggest that it is impossible to set cmd.exe to run as admin automatically.


Attached Images
Can't run .bat files-bat1.png 
My System SpecsSystem Spec
21 Feb 2015   #6
Brink

64-bit Windows 10 Pro
 
 

Ok, so it's just not finding the .bat file instead.

Is this a shortcut of the .bat file you are trying to run? If so, are you able to directly run the .bat file?
My System SpecsSystem Spec
21 Feb 2015   #7
RolandJS

Windows 7 Professional 64-bit
 
 

https://answers.microsoft.com/en-us/...2-a7312316a4b4

I'm not sure if the above will of any help; can't make things any worse, I guess.
My System SpecsSystem Spec
21 Feb 2015   #8
Peter57r

windows 7 64
 
 

I'm not using any shortcuts. I'm trying to run the .bat files directly by double-clicking or Using Open.
If I use the command processor and navigate to the folder, i can run the bat file from there. (see below)


Attached Images
Can't run .bat files-bat2.png 
My System SpecsSystem Spec
21 Feb 2015   #9
Peter57r

windows 7 64
 
 

Thanks RolandJS
I'm afraid I've already applied that 'fix' - I deleted the UserChoice key.
My System SpecsSystem Spec
21 Feb 2015   #10
Brink

64-bit Windows 10 Pro
 
 

Are you having this issue with all .bat files, or just this specific one?

As a test, copy the .bat file to your desktop, and see if you are able to run it.

If not, then rename the .bat file, and try again.
My System SpecsSystem Spec
Reply

 Can't run .bat files




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Windows 7 won't boot, SFC found corrupt files, hdd/files still intact
I get a windows boot error 0xc000000e if I try to boot into safe mode or launch startup repair through through windows boot manager. I tried using a windows 7 recovery usb but startup repair says it cannot repair the problem automatically. Through the command line I ran chkdsk /f and /r multiple...
Performance & Maintenance
.wma files appears as .dat files in Temporary Internet Files folder
Hi, I am running IE8 on Windows 7 (Home Premium 64bit). My Temporary Internet Files folder is C:\Users\<username>\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5. I have enabled Show Hidden Files and Folders and removed the tick for Hide Protected Operating System...
Browsers & Mail
worrd 2007 only opening old files, not open revised files
My wife has Win7 home premium x64 on her laptop and is using Word 2007. The problem she is having is she will open a word file, change it up, save it, then re-open it later and its the old file not the new one. Where as I can open the edited file on my desktop running the same OS but with Word...
Microsoft Office
error-failed to load locale files from "Program Files\Western Digital\
failed to load locale files from "Program Files\Western Digital\WD Smartware\Locale" The menu box it's under is entitled " WDContextMenuHandler " I get this error when I just right click on any part of "my computer" everytime. the pc then goes blank on desktop while it says " windows...
BSOD Help and Support
.reg files open Notepad - do not change registry to read older files
Running Win7Pro 64-bit. Am unable to open older Office 97 files with Office2003 which is installed and running fine. I found a couple of files here and elsewhere with .reg extensions that were supposed to make the necessary registry changes. eg. "UnlockWord.reg" and a more elaborate-looking...
Microsoft Office
Offline files doen't update files changed locally
My offline files seems to work offline all the time, even when it shows me being online. I sync most of my business files to my laptop for working at home at night. When I edit a file from my Win 7 (pro, 64-bit) laptop, then go to edit it again, I get the version I had changed, but no one else...
Network & Sharing


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 05:39.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App