2

I've found variants of this question being asked all over the place, and I've attempted all of the actual answer I've found out there (including changing the registry for associations). The basic issue is this:

  1. I create a batch file (simple batch that has an echo and a pause) on the desktop or in any folder in the computer.
  2. I double click the batch file to run it and get:

enter image description here

Workarounds include:

  1. Right click and run as administrator
  2. Open command prompt and call the batch file by name

I was dealing with the issue by just using those workarounds for a while, but I'm starting to think my inability to get certain programs to work properly (android.bat in Android Studio won't run because of file not found despite being there, for instance) is related to this issue. If I can't get it fixed in the next week, I'm likely going to reformat.

Additional info:

  1. This is Windows 8.1 Pro 64-bit
  2. There are no other file types which have this double-click execution issue
  3. If I call a batch file from another batch file using the workarounds, it works
  4. This happens regardless of the folder I'm in, and does not happen on a Hyper-V virtual machine using the same copy of windows
  5. All windows updates are run and I've done virus scans and such - the only other thing that's been going wrong simultaneously is that the machine seems to be slowing down a bit (in particular when I try to open file dialogs in ANY program - which now take ~5 seconds to open instead of being instantaneous).

Any ideas would be much appreciated! It may just be time for a reformat (it's been a year or so).

Edit: Wasn't aware of SuperUser. Seems like this question may be more appropriate over there!

Edit 2: Anyone over here have an ideas?

4
  • Try fixing .BAT-related registry entries via the File Association Fixer, reboot and see if it works.
    – Karan
    May 7, 2015 at 19:30
  • Just tried it and rebooted, no effect at all.
    – user986122
    May 7, 2015 at 21:32
  • Have you run sfc /scannow already? If you create a new user do batch files work? If not what are your user and system PATH variables set to?
    – Karan
    May 7, 2015 at 22:08
  • Just finished running, "Verification 100% complete. Windows Resource Protection did not find any integrity violations."
    – user986122
    May 7, 2015 at 23:26

3 Answers 3

6

Check your system environment COMSPEC. It should be something look like %SystemRoot%\system32\cmd.exe. If it was altered for what ever reason , bat files won't be able to run by double click.

1
  • My problem solved following this guideline!
    – Say OL
    Nov 22, 2016 at 5:01
1

You are running the Batch File in a "privileged space". Microsoft has become wise to this fact, and you need to address this accordingly.

Most viruses and malware exploit the root of the OS Drive.

What you need to do is to create a folder and move your batch file in there.

C:\test\test.bat

As an aside, in the "server world" it is actually considered to be a poor practice to install/run your application on the same drive as the OS. Consumer laptops/desktops is fine, but in the server space, this is a bad practice. For example, if your web server or database was to run an errant process, and the log space was to fill the drive, it can quite literally kill the OS.

Just my couple bits for thoughts.

Thanks.

10
  • Thanks for the reply! As I mentioned, it doesn't matter what folder I put it in. I did that to avoid including my username information in the path. The typical path is C:\Users\<username>\Desktop\test.bat . I would never put something in C: except for demo purposes.
    – user986122
    May 6, 2015 at 19:42
  • Are your users set to be Power Users or better? Do you need to apply CACLS/XCACLS on the folder/file to apply appropriate permissions? And, what is in the content of the bat file?
    – Leptonator
    May 6, 2015 at 19:44
  • As I mentioned in the question, I just echo and pause. The file runs if I use a non-admin command prompt. Double-clicking is the time it doesn't run.
    – user986122
    May 6, 2015 at 19:46
  • I would look at your ePO, and/or virus Settings/Policies. Your Sys Admin may have put restrictions against running batch files. You have to think in those terms.
    – Leptonator
    May 6, 2015 at 19:49
  • Well this is a personal computer so I am my sys admin. I'll check that though, thanks!
    – user986122
    May 6, 2015 at 19:51
-1

I copied the "cmd.exe" file from another PC and pasted it into the windows/system32/ folder. That fixed my problem.

1
  • I don't see how this would make a difference. However, to give you the benefit of the doubt, I am not voting to delete this answer. But the answer requires a reason. Did you get the idea from somewhere, did they post a reason ? Dec 20, 2022 at 5:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .