Page 1 of 1

Command promt ignoring PATH variable if opened from XYPlorer

Posted: 12 Apr 2016 15:25
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

Re: Command promt ignoring PATH variable if opened from XYPl

Posted: 12 Apr 2016 15:53
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

Re: Command promt ignoring PATH variable if opened from XYPl

Posted: 12 Apr 2016 17:32
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.

Re: Command promt ignoring PATH variable if opened from XYPl

Posted: 12 Apr 2016 18:01
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?

Re: Command promt ignoring PATH variable if opened from XYPl

Posted: 12 Apr 2016 18:44
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 ? ;)

Re: Command promt ignoring PATH variable if opened from XYPl

Posted: 12 Apr 2016 18:53
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

Re: Command promt ignoring PATH variable if opened from XYPl

Posted: 12 Apr 2016 19:05
by highend
I think I've found a solution
That's the one that I would have suggested...