0

I have a file called myfile.txt and this file lives in C:/files/myfile.txt. I have C:/files in the PATH environment variable. When I do echo %PATH% I do in fact see C:/files. But when I try to do type "myfile.txt" it says The system cannot find the file specified. Also interestingly, an executable, like C:/files/my_program.exe works fine when I write just my_program. So why can Windows detect executables only, and not other file types in my directory?

  • Type `dpath /?` for the data file equivalent of `path`. Note the older name is `append` and the help still calls it that. This is depreciated since 1984 I think. –  Apr 11 '20 at 05:20
  • Is this something I have to do each time in a `cmd`? What is the point of `PATH` if I have to append the paths all over again? –  Apr 11 '20 at 05:22
  • It purpose is in MSDos Ver 2 and later to let MSDos Ver 1 programs find data files in subdirectories which only came in in Ver 2. –  Apr 11 '20 at 06:01
  • CMD can run any command on startup. See `cmd /?` (the `/d`) - `AutoRun` `HKCU\Software\Microsoft\Command Processor` –  Apr 11 '20 at 06:06
  • 1
    Please read the Microsoft article about [Naming Files, Paths, and Namespaces](https://learn.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). You can read there that the directory separator on Windows is ``\`` and not `/` as used by you. So you should use in future the backslash character and not the slash character in file/folder paths. Next please read from top to bottom my answer on [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/a/41461002/3074564) – Mofi Apr 11 '20 at 06:12
  • Also (to type just myfile) `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Myfile.EXE` `@="C:\files\myfile.txt"` (or to type myfile.txt) `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Myfile.txt` `@="C:\files\myfile.txt"` To use `start myfile`. –  Apr 11 '20 at 06:52
  • The `PATH` variable is intended to store paths to find *executables* (to be precise, those with a file name extension specified in `PATHEXT`); to find *data files* you can use `DPATH`, or simply specify the full file path... – aschipfl Apr 11 '20 at 11:50
  • Is it safe to do `set DPATH=%PATH%` ? –  Apr 11 '20 at 16:53
  • Yes it is. Although it is a security hole but then nothing would target it as nobody uses it. –  Apr 13 '20 at 05:43

0 Answers0