Can't run .bat files

Page 1 of 3 123 LastLast

  1. Posts : 11
    windows 7 64
       #1

    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:

    https://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 Computer


  2. Posts : 2,774
    Windows 7 Professional 64-bit
       #2

    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 Computer


  3. Posts : 16
    Windows 7 Ultimate x64/Windows xp Media center edition x64(Dual boot)/Windows10,Windows7,Ubuntu(64)
       #3

    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\" %*"
    Can't run .bat files Attached Files
    Last edited by Randycool79; 20 Feb 2015 at 11:25.
      My Computer


  4. Posts : 72,051
    64-bit Windows 11 Pro for Workstations
       #4

    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 Computer


  5. Posts : 11
    windows 7 64
    Thread Starter
       #5

    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 Thumbnails Attached Thumbnails Can't run .bat files-bat1.png  
      My Computer


  6. Posts : 72,051
    64-bit Windows 11 Pro for Workstations
       #6

    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 Computer


  7. Posts : 2,774
    Windows 7 Professional 64-bit
       #7

    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 Computer


  8. Posts : 11
    windows 7 64
    Thread Starter
       #8

    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 Thumbnails Attached Thumbnails Can't run .bat files-bat2.png  
      My Computer


  9. Posts : 11
    windows 7 64
    Thread Starter
       #9

    Thanks RolandJS
    I'm afraid I've already applied that 'fix' - I deleted the UserChoice key.
      My Computer


  10. Posts : 72,051
    64-bit Windows 11 Pro for Workstations
       #10

    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 Computer


 
Page 1 of 3 123 LastLast

  Related Discussions
Our Sites
Site Links
About 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 14:02.
Find Us