Command promt ignoring PATH variable if opened from XYPlorer

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
lilivier
Posts: 25
Joined: 30 Mar 2016 11:49

Command promt ignoring PATH variable if opened from XYPlorer

Post by lilivier »

Hello,

I don't understand why but there is a problem if I open a command prompt (cmd.exe) with the 'Open Command Prompt Here' button:

It seems the command prompt opened by XYPlorer cannot find .bat or .exe files that are in folders referenced by my system PATH environment variable.

A good example is the java.exe which is located in C:\Windows\System32\java.exe.

If I open a command prompt directly from Windows start menu I can call java -version correctly:

If I open a command prompt from XYPlorer, java -version does not work as java.exe cannot be found.
I get: 'java' is not recognized as an internal or external command.

If I perform a where java in a normal command prompt, it display its path:
C:\Users\maol>where java
C:\Windows\System32\java.exe


When the command prompt is opened from XYPlorer it cannot find anything.

OS: Windows 10 Pro
Xplorer version: 16.50.0200

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Command promt ignoring PATH variable if opened from XYPl

Post by highend »

Tried 16.60 (latest official release), fresh installation on a fresh Win 10:

java -version from a command prompt opened through the toolbar icon works absolutely fine...

Show a screenshot of the Menu - Tools - Configuration... - Templates page
One of my scripts helped you out? Please donate via Paypal

lilivier
Posts: 25
Joined: 30 Mar 2016 11:49

Re: Command promt ignoring PATH variable if opened from XYPl

Post by lilivier »

I have not changed anything in the Templates configuration:

Image

I just tried to open a command prompt from XYPlorer in the directory C:\Windows\System32.
If I do a dir it does not display java.exe:

Image

If I open a command prompt directly from Windows, the dir command correctly displays the java.exe:

Image

Note that I have correctly started XYPlorer.exe as Administrator.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Command promt ignoring PATH variable if opened from XYPl

Post by highend »

I see. This is a file system redirection problem...

Do the following:
1. Create a folder named "Sysnative" in "C:\Windows"
2. Configuration | Templates | Use custom command line interpreter (else default to cmd.exe)
Check that box and for the executable use:
C:\Windows\Sysnative\cmd.exe

Restart XY, open a dos box in "C:\Windows\System32" again and do your "dir j*"
Does it work?
One of my scripts helped you out? Please donate via Paypal

lilivier
Posts: 25
Joined: 30 Mar 2016 11:49

Re: Command promt ignoring PATH variable if opened from XYPl

Post by lilivier »

Yes! it works after creating the C:\Windows\Sysnative folder inside Windows Explorer :)
Note that I had to use Windows Explorer because I was first not able to create it through XYPlorer. It told me that the folder already exist.

Now I still got another problem: I would like to use Clink which is a replacement for cmd.exe (mainly because I need to retain command history between sessions) :

https://mridgers.github.io/clink/


I unzipped the portable version of Clink in a folder ( C:\clink for example), then I modified the custom command line interpreter to use:
C:\clink\clink.bat

But then I get again the redirection problem again (java.exe not found).

clink.bat is calling cmd.exe:

Code: Select all

:launch
start "Clink" cmd.exe /s /k ""%~dpnx0" inject %clink_profile_arg%"
exit /b 0
Should I modify the way cmd.exe is called in the .bat ? If yes, how ? ;)

lilivier
Posts: 25
Joined: 30 Mar 2016 11:49

Re: Command promt ignoring PATH variable if opened from XYPl

Post by lilivier »

I think I've found a solution.

I replaced cmd.exe by C:\Windows\Sysnative\cmd.exe in clink.bat ;)

Code: Select all

:launch
start "Clink" C:\Windows\Sysnative\cmd.exe /s /k ""%~dpnx0" inject %clink_profile_arg%"
exit /b 0

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Command promt ignoring PATH variable if opened from XYPl

Post by highend »

I think I've found a solution
That's the one that I would have suggested...
One of my scripts helped you out? Please donate via Paypal

Post Reply