Windows cannot find .bat. Make sure you typed the name correctly, and then try again

8,189

Okay, some of you might think I'm stupid but this is how I solved this issue.

I went into my environment variables and was looking for COMSPEC but instead I found ComSpec. Once I renamed it back to COMSPEC everything started working again.

I have no idea how it was even renamed in the first place but that fixed my issue.

Hope this helps other people with this issue.

Share:
8,189

Related videos on Youtube

CyanFlare
Author by

CyanFlare

Updated on September 18, 2022

Comments

  • CyanFlare
    CyanFlare over 1 year

    I have no idea when this started to happen but it is preventing me from opening .bat files on double click. I am only able to run it as administrator. Is there anyway to fix this so i can double click instead of running as administrator? This causes some programs not to work.

    I've tried to reset the file association in the registry, checked the environment variables, and I checked to see if cmd was actually in the System32 folder.

    If more info is needed, I will try to provide it.

    • harrymc
      harrymc over 5 years
      You need to show us a screenshot of what happens in a Command Prompt window, and also the file association registry entries.
    • CyanFlare
      CyanFlare over 5 years
      Here is an image of the error. i.imgur.com/789l25n.png
    • Vomit IT - Chunky Mess Style
      Vomit IT - Chunky Mess Style over 5 years
      You might try first from command line run FTYPE batfile="%1" %* and then run ASSOC .bat=batfile, and see if that helps. If not, then from an admin elevated command prompt, type in sfc /scannow and press Enter. Let that complete, reboot the PC, and then try again.
    • harrymc
      harrymc over 5 years
      Apart from the advice by @PimpJuiceIT, I notice that the .bat file is on the desktop. Try to copy it to some folder and start it from there. This might be a matter of permissions.
    • CyanFlare
      CyanFlare over 5 years
      I tried what pimp juice and harrymc said but i still cannot open the bat file.
  • CyanFlare
    CyanFlare over 5 years
    This did not fix the issue.
  • Squashman
    Squashman over 5 years
    Environmental variables are not case sensitive. My compsec variable is in camel case and works just fine. ComSpec=C:\WINDOWS\system32\cmd.exe
  • fixer1234
    fixer1234 over 5 years
    If this change fixed it for you, it suggests that the problem was a hiccup, and not reproducible.
  • Salman
    Salman about 3 years
    How in the world that works out :P I was running into Flutter setup error and this helped me out after long hours of struggling. Thanks a lot.
  • Charles Kenyon
    Charles Kenyon almost 3 years
    I do not see Squashman, above. Are you perhaps posting in the wrong question?
  • RipSurge
    RipSurge almost 3 years
    He commented on the above posted (currently chosen/voted) answer on Nov 29 '18. You should see it as a comment/reply below the original poster's answer posted above.