Double-click to run .bat - Windows cannot find file

Page 3 of 3 FirstFirst 123

  1. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #21

    Kan,

    Are you sure there are no special characters in the folder path or filename that could be messing things up?

    Does the error message display the folder path & filename correctly? Perhaps you could post a screenshot of the error dialog.

    Do check that you have not renamed any part of the folder path or filename without refreshing the view [F5 or right-click, Refresh].

    Denis
      My Computer


  2. Posts : 107
    Windows 10 64 bit Home 22H2 (always completely updated)
       #22

    thanks again Denis!

    ***
    Are you sure there are no special characters in the folder path or filename that could be messing things up?
    ***
    yes I am

    ***
    Does the error message display the folder path & filename correctly? Perhaps you could post a screenshot of the error dialog.
    ***
    yes it does

    ***
    Do check that you have not renamed any part of the folder path or filename without refreshing the view [F5 or right-click, Refresh].
    ***
    I restarted several times, even put back an old image, but to no avail in this department.


    Here's some more information/speculation:

    -when I run any batch file directly the error-message 'cannot find the file' appears. It it the regular windows error (see page 1) that shows reference to the file one tried to run. This message is wrong, but the reference to the file is correct everytime
    -when I run batchfiles through a .lnk (with admin rights) they work fine, when run through a .lnk without admin rights they fail just like when I run them directly
    -I attach the file I was fumbling around with last night that may have started the trouble. Nothing special. Readers could open it as a text file.
    -What I first thought may have happened: it is a file that helps rename all files in a folder (by calling a nifty program 'Renamer') and maybe (I am not certain) something like this happened: the script calling the program renames files in the the folder, including the batchfile in use to do the renaming at all. You would expect an error in this case, but maybe something twisted happened. What counters this idea is that I can run all other files in the folder (it is a folder for testing purposes that contains textfiles, all appear to be fine). Second: this error concerns all batchfiles, not just the one in the folder.
    -Anyhow, I put back an old image. Ran chkdsk twice and my ntfs had two errors repaired (possibly unrelated, could not tell), but the problem persists. Under Linux all seems normal. Further I ran the .bat-file repair from this forum and the File Association Fixer. To no avail as yet.
    -Could this be a permissions issue (message number six by Dalchina, that refers to a webpage that does not help)? And if so, where to start repair of permission to run my own files on my own machine ?

    renamerscript.bat

    Thanks in advance, kind regards, Kazzy
    Last edited by Kan Lang; 10 Dec 2022 at 13:41.
      My Computer


  3. Posts : 6,849
    22H2 64 Bit Pro
       #23

    See Post #23 and earlier posts in this thread.

    Can't run .bat files Solved - Page 3 - Windows 7 Forums
      My Computer


  4. Posts : 107
    Windows 10 64 bit Home 22H2 (always completely updated)
       #24

    Solved!! Thanks Callender!

    Just for the sake of being complete I hereby add what helped me (from a post by Pyprohly):

    ***
    For anyone else with a broken ComSpec variable (and can't run batch files), with an Elevated Command Prompt,
    Code to reset the environment variable to what it should be:

    setx ComSpec %SystemRoot%\system32\cmd.exe /m

    ***

    I did not mention it in my post just before, but I have been wondering if something had happened to my PATH.

    -are PATH and environment connected? What is environment anyway and how can I see what the environment and path settings are? When I enter 'comspec' in a cmd window it is not recognized. I am probably mashing things up here
    -my problem is solved: great! But what has happened so that even restoring an old image seemed not to be of help (this must be wrong, I assume, but still: what happened? Did I somehow destroy the environment setting using my own batchfile? And will it happen again?).

    Many thanks, regards, Kazzy
      My Computer


  5. Posts : 6,849
    22H2 64 Bit Pro
       #25

    If you run sysdm.cpl

    Winkey+R then enter sysdm.cpl you can see environment variables. Don't know why/ what screwed up. I just remember that old thread that I posted.

    Double-click to run .bat - Windows cannot find file-environment-variables.jpg
      My Computer


  6. Posts : 107
    Windows 10 64 bit Home 22H2 (always completely updated)
       #26

    Thanks a lot, greatly appreciated (as for the other contributors). I know how to solve in case this goes wrong again. Regards, Kazzy
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 23:13.
Find Us




Windows 10 Forums