interesting run SC bug [NotABug]

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

interesting run SC bug [NotABug]

Post by bdeshi »

Try this:

Code: Select all

::writefile("echo.bat", "cmd /K echo HI!", o); run "echo.bat";
Right, that went well. Now try this:

Code: Select all

::writefile("cmd.bat", "cmd /K echo HI!", o); run "cmd.bat";
Did it go well too?
Now, try the first code again.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 67299
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: interesting run SC bug.

Post by admin »

Wow, what's that?! Same BAT behavior in Explorer. And when you move the BAT to a new location it behaves normal again. Looks like a Windows bug to me.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: interesting run SC bug.

Post by bdeshi »

Yeah, I suspected MS might have a hand in it.
It's so... unimaginable!
I guess XY is off the hook for this one. Or did you fix it already? :wink:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: interesting run SC bug.

Post by TheQwerty »

No bug.

Executing a program without specifying its extension causes Windows to search for the first matching executable using the extensions defined by %PATHEXT% in the working directory and if none is found there search the locations specified by %PATH%. (There is also some registry diving but I cannot recall the details at present.)

If you had used 'cmd.exe /K echo HI!' it would work as you expect.
However, '%ComSpec% /K echo HI!' is better still.


EDIT: Some further information...

From a command prompt there is no registry diving.
It checks the current directory and each location in %path% for 'cmd.*'.
If/when a match is found it then goes through the extensions in %pathext% checking for 'cmd.<ext>'.
It repeats this until a match is found or it exhausts %path%.

From the Run dialog or Start menu...
It checks 'HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\cmd.exe' and the same under 'HKLM'.
If either key is a match it will attempt to use the '(Default)' key's value as the path to the executable (and maybe some other child keys - I'm not positive).
Otherwise it does the same as above.

Granted this is Windows 7 so it may have changed since.

Post Reply