echo %0 does not display extension (.cmd)
Posted: 13 Jun 2024 02:50
I have a strange situation:
User runs a .cmd from command prompt and receives an error (findstr command to search within %0):
batch_filename.cmd:
I checked my computer and in the system settings I have 'File name extensions' checked (open File Explorer -> View -> File name extensions). I played with this and if I run a .cmd (@echo %0&pause) it displays extension regardless of this settings. From command prompt it does not work after I changed settings (and even if I enable it again) (I cannot reboot the computer at the moment to see the result).
I use this FINDSTR within a FOR statement so I thought that this might have something to do with this (because new CMD.EXE is executed and would default to another working direcotory) - if this would be the case @echo %0 (not used within FOR) would work always.
Ideas?
Update: I created another .cmd in a way that FINDSTR command writes to a temporary file which is then read by FOR. When users makes a test I will write an update to this post.
Thanks.
Saso
User runs a .cmd from command prompt and receives an error (findstr command to search within %0):
batch_filename.cmd:
Code: Select all
FINDSTR: Cannot open batch_filename <----- note there is no extension displayed
I use this FINDSTR within a FOR statement so I thought that this might have something to do with this (because new CMD.EXE is executed and would default to another working direcotory) - if this would be the case @echo %0 (not used within FOR) would work always.
Ideas?
Update: I created another .cmd in a way that FINDSTR command writes to a temporary file which is then read by FOR. When users makes a test I will write an update to this post.
Thanks.
Saso