Cannot execute a command via a symbolic link

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
RichieTheK
Junior Member
Junior Member
Posts: 5
Joined: 2008-08-16, 10:06 UTC

Cannot execute a command via a symbolic link

Post by *RichieTheK »

I cannot use the Total Commander command line to execute a command that is referenced through a symbolic link. An error message stating "Search path not found!" appears.

Win7 64-bit, TC 8.0RC3 64-bit and 32-bit

I created a simple test case as follows:
In an empty directory "temp"
mkdir foo
copy c:\windows\system32\notepad.exe foo
mklink np.exe foo\notepad.exe (requires elevated/admin permissions)

With TC having focus on "temp", try to execute np.exe.
The error message will appear.

Clicking on np.exe in the pane works, you just cannot use the TC command line.
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hello, RichieTheK.

Try to use an absolute pathname instead of a relative pathname in your mklink commandline.

Code: Select all

mklink np.exe C:\Temp\foo\notepad.exe
provided this is where notepad.exe has been copied to.
When trying to execute np.exe from a commandline keep in mind that np.exe itself is located inside C:\Temp which is unlikely to be included in the %PATH% variable.
Hence at the command prompt you will have to execute

Code: Select all

C:\temp\np.exe
Kind regards,
Karl
MX Linux 21.3 64-bit xfce, Total Commander 11.50 64-bit
The people of Alderaan keep on bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine.
The Prophet's Song
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

RichieTheK, please try to double-click your symlink in Explorer, it shows error too. :D And it is strange because it can be started via Win+R, CMD.exe, Enter or double-click from TC. Also it can be started from TC command line using full path (Ctrl+Shift+Enter)

Symlinks are strange objects, they can't transfer dates and sizes, their creation requires elevation etc. If you want to start notepad from TC command line by typing just np, maybe you should create an alias for Notepad.exe in Configuration\Misc TC dialog.
RichieTheK
Junior Member
Junior Member
Posts: 5
Joined: 2008-08-16, 10:06 UTC

Post by *RichieTheK »

KarlChen - The symlinks that I create for day-to-day use do contain absolute paths. The link is created in a utility directory that is on the search path. The target is an absolute reference to an executable which is not on the search path. I'm sorry that the test case that I created used relative paths and gave the wrong impression. In any case, regardless of whether the target is absolute or relative, I get the same error: "Search path not found!". The symlinks work from the command-processor and through direct clicking, just not from the TC command line.

MVV - I agree that symlinks are strange. I realize that I could use "alias", but I was hoping that I wouldn't have to duplicate the effort, creating a symlink for use with the command-processor and an additional alias for TC.

Thanks for your replies.
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hello, RichieTheK.

OK. I think I do understand the problem better now:
  • Target executable: D:\LOCAL-Data\Utils\Notepad2\Notepad2.exe (folder not included in %PATH%)
  • Current folder: C:\windows\system32 (definitely included in %PATH%)
  • Command: mklink np.exe D:\LOCAL-Data\Utils\Notepad2\Notepad2.exe
  • Running np from any folder in cmd.exe: Notepad2 will be launched.
  • Running np from the Total Commander commandline: Error Message "Search path not found!"
  • Running C:\Windows\system32\np.exe from the Total Commander commandline: Notepad2 will be launched.
This might suggest that the T.C. commandline has not got access to the %PATH% variable.
But it has. Proof:
  • Running notepad from the Total Commander commandline: Notepad is launched.
Hm. Problem reproduced. Confusion has not gone away. :?

Cheers,
Karl
MX Linux 21.3 64-bit xfce, Total Commander 11.50 64-bit
The people of Alderaan keep on bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine.
The Prophet's Song
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I think strangest thing is that Explorer can't run np.exe by double-click. :D
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

This seems to be a bug in ShellExecuteEx function. Maybe someone can test that...
Author of Total Commander
https://www.ghisler.com
Post Reply