Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

When connecting through SSH tunnel, look for plink.exe on PATH

bazzilic's profile image bazzilic posted 3 years ago in Creating a connection Permalink

As far as I understood, right now HeidiSQL would not detect plink.exe on PATH. However, if you install PuTTY through Chocolatey, it puts plink on PATH. I would also assume, that many people put putty executables on PATH manually. So, probably, it makes sense for HeidiSQL to check if it's available there.

ansgar's profile image ansgar posted 3 years ago Permalink

I am using CreateProcess() to fire the configured path to plink.exe, with the current directory as lpCurrentDirectory parameter. That does not mean that plink.exe has to exist there - you can always point the path to some other directory. However, I don't know if that also finds a plink.exe somewhere in your path environment without having a folder in the HeidiSQL plink.exe setting. Try it out?

bazzilic's profile image bazzilic posted 3 years ago Permalink

Do you pass the path to plink as lpApplicationName or as lpCommandLine? As I understood from MSDN, the first one would not search PATH, and the second one would.

However, it is not entirely clear in the documentation.

Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.
bazzilic's profile image bazzilic posted 3 years ago Permalink

Also, yeah, I tried before posting, it doesn't see plink on the PATH (I tried putting plink and plink.exe and neither worked).

ansgar's profile image ansgar posted 3 years ago Permalink

Currently, HeidiSQL passes the whole string from the plink.exe setting as lpApplicationName parameter, e.g. c:\some\where\plink.exe.

lpCommandLine is then populated with parameters which plink expects, such as -N -L....

If I read the docs correctly, then I could make use of case 2:

On the other hand, if the CommandLine parameter is non-NULL and the ApplicationName parameter is NULL, then the API attempts to extract the application name from the CommandLine parameter.

With some luck, that case will work with an executable on the path variable:

CreateProcess(nil, 'plink.exe -N -L[more parameters]', ...)
bazzilic's profile image bazzilic posted 3 years ago Permalink

From what I got from the docs, it should do the trick.

Code modification/commit 5534275 from ansgarbecker, 3 years ago, revision 5110
Move plink.exe path to lpCommandLine parameter instead of passing it as lpApplicationName. This way, a folderless plink.exe call should use the first available one from the path environment. See http://www.heidisql.com/forum.php?t=21873
ansgar's profile image ansgar posted 3 years ago Permalink

r5110 does exactly that. In my tests, I could use a folderless "plink.exe" which then was taken from a folder from my path environment variable. Also, having a folder in that setting does not seem to harm here. Also, having spaces in the path to plink.exe still works here.

Please test yourself after updating heidisql.exe.

bazzilic's profile image bazzilic posted 3 years ago Permalink

Thanks!

Please login to leave a reply, or register at first.