[GH-ISSUE #59] WinScp connection type #1003

Closed
opened 2026-02-28 12:00:45 +03:00 by kerem · 20 comments
Owner

Originally created by @majkinetor on GitHub (Jan 13, 2021).
Original GitHub issue: https://github.com/1Remote/1Remote/issues/59

We could have WinScp type of connection, the same way we use kitty.

WinScp is stable, automatable and awesome, and it has some unique features, such as real time copy of changed local files to remote.

/cc @VShawn

Originally created by @majkinetor on GitHub (Jan 13, 2021). Original GitHub issue: https://github.com/1Remote/1Remote/issues/59 We could have WinScp type of connection, the same way we use kitty. WinScp is stable, automatable and awesome, and it has some unique features, such as real time copy of changed local files to remote. /cc @VShawn
kerem closed this issue 2026-02-28 12:00:45 +03:00
Author
Owner

@VShawn commented on GitHub (Jan 14, 2021):

2 problems we facing:

  1. UX fail:
  2. Legal Risk
    • good news is both WinSCP and PRemoteM are in GPL3.0
    • just not sure if it is OK that embed WinSCP into PRemoteM
<!-- gh-comment-id:759853321 --> @VShawn commented on GitHub (Jan 14, 2021): 2 problems we facing: 1. UX fail: - As I mentioned in https://github.com/VShawn/PRemoteM/issues/56#issuecomment-758639688 that embedded programs will meet some UX problems. - We may need to add some code into WinSCP and compile it as what I did in [Kitty_PRM](https://github.com/VShawn/KiTTY_PRM) 2. Legal Risk - good news is both WinSCP and PRemoteM are in GPL3.0 - just not sure if it is OK that embed WinSCP into PRemoteM
Author
Owner

@VShawn commented on GitHub (Jan 14, 2021):

try mRemotNG with WinScp, got UX fail when integrate.
image

<!-- gh-comment-id:759889346 --> @VShawn commented on GitHub (Jan 14, 2021): try mRemotNG with WinScp, got UX fail when integrate. ![image](https://user-images.githubusercontent.com/10143738/104537923-d4f58080-5655-11eb-8e9e-571d6ef887af.png)
Author
Owner

@majkinetor commented on GitHub (Jan 14, 2021):

ConEmu does this - it can embed any GUI into its frame.

<!-- gh-comment-id:759890812 --> @majkinetor commented on GitHub (Jan 14, 2021): ConEmu does this - it can embed any GUI into its frame.
Author
Owner

@majkinetor commented on GitHub (Jan 14, 2021):

Here is how it looks like in ConEmu as a split.

image

This is also unmodified kitty, in a tab:

image

It wouldn't work immediately by just calling kitty as it will open settings editor and console will not catch it. I also tried with a saved session and used command kitty -load <session_name> but it still was out of ConEmu window.. However, I used ConEmu acommand Attach to_ which lets you select any running executable and then it worked. Command line option classname to define a specific class name for the window might help in automating this and that means that unmodified kitty can be used. This could lead to PRM options of the form use available local tools where PRM just requires they are on the PATH by default or lets you specify full path. Also, not having to rebase your work on top of latest kitty is huge improvement, and will allow people to update kitty (and potentially other tools PRM uses) via other means such as chocolatey.

I see in your kitty_PRM commit that you had to find last hwnd, which can probably be avoided by starting it, waiting for the class and obtaining its hwnd, then changing its parent using Windows API.

just not sure if it is OK that embed WinSCP into PRemoteM

Thats why it is in Limbo milestone, at this point I just recorded it as idea and to have historic reference in case somebody else is interested.

Not sure why you think its not OK ? Why is this ANY different then embedding kitty ? Are you concerned about the size of the final product ? I

<!-- gh-comment-id:760095235 --> @majkinetor commented on GitHub (Jan 14, 2021): Here is how it looks like in ConEmu as a split. ![image](https://user-images.githubusercontent.com/85767/104573444-2c472100-5655-11eb-8e6c-b349ae7bfbbb.png) This is also unmodified kitty, in a tab: ![image](https://user-images.githubusercontent.com/85767/104575084-120e4280-5657-11eb-9220-8188bdc3f50b.png) It wouldn't work immediately by just calling kitty as it will open settings editor and console will not catch it. I also tried with a saved session and used command `kitty -load <session_name>` but it still was out of ConEmu window.. However, I used ConEmu acommand _Attach to__ which lets you select any running executable and then it worked. Command line option `classname` to define a specific class name for the window might help in automating this and that means that unmodified kitty can be used. This could lead to PRM options of the form _use available local tools_ where PRM just requires they are on the PATH by default or lets you specify full path. Also, not having to rebase your work on top of latest kitty is huge improvement, and will allow people to update kitty (and potentially other tools PRM uses) via other means such as chocolatey. I see in your kitty_PRM commit that you had to find last hwnd, which can probably be avoided by starting it, waiting for the class and obtaining its hwnd, then changing its parent using Windows API. > just not sure if it is OK that embed WinSCP into PRemoteM Thats why it is in Limbo milestone, at this point I just recorded it as idea and to have historic reference in case somebody else is interested. Not sure why you think its not OK ? Why is this ANY different then embedding kitty ? Are you concerned about the size of the final product ? I
Author
Owner

@VShawn commented on GitHub (Jan 14, 2021):

Are you concerned about the size of the final product ?

yes I wanna keep the tool tiny and simple, in my early design PRM was just a launcher, it will work with rdprunner.exe/putty.exe/sftp.exe/e.t. And putty was never been modified at that time. But I finally find it difficuly to handle RDP toggle between fullscreen and window, PuTTY always meeting UX problems in this mode.Then RDP become a Native component of PRM and KiTTY was rebased.

Now I still hope to be able to keep this mode of integrating external apps.The more apps we integration, the less code for us to maintain, only if we can fix UX problems.

BTW you can run KiTTY without opening editor with

kitty.exe -ssh {Address} -P {Port} -l {UserName} -pw {Password} -{(int)SshVersion}
e.g. KiTTY.exe -ssh 127.0.0.1 -P 22 -l "user" -pw "123"

<!-- gh-comment-id:760118672 --> @VShawn commented on GitHub (Jan 14, 2021): > Are you concerned about the size of the final product ? yes I wanna keep the tool tiny and simple, in my early design PRM was just a launcher, it will work with rdprunner.exe/putty.exe/sftp.exe/e.t. And putty was never been modified at that time. But I finally find it difficuly to handle RDP toggle between fullscreen and window, PuTTY always meeting UX problems in this mode.Then RDP become a Native component of PRM and KiTTY was rebased. Now I still hope to be able to keep this mode of integrating external apps.The more apps we integration, the less code for us to maintain, only if we can fix UX problems. BTW you can run KiTTY without opening editor with >kitty.exe -ssh {Address} -P {Port} -l {UserName} -pw {Password} -{(int)SshVersion} > e.g. KiTTY.exe -ssh 127.0.0.1 -P 22 -l "user" -pw "123"
Author
Owner

@majkinetor commented on GitHub (Jan 14, 2021):

yes I wanna keep the tool tiny and simple

We could also offer 2 versions - one with tools, other without them. Not sure if its worth it the hessle.

BTW you can run KiTTY without opening editor with

That is similar to -load and it behaves the same in ConEmu - the main kitty exe seems to exit asap and relaunch in either scenario.

The more apps we integration, the less code for us to maintain, only if we can fix UX problems.

Not only that, but security will be better (as you can keep tools up to date no matter what is in PRM), and that way it allows for potential cross platform (you can't really pack binaries for each system...).

<!-- gh-comment-id:760124496 --> @majkinetor commented on GitHub (Jan 14, 2021): > yes I wanna keep the tool tiny and simple We could also offer 2 versions - one with tools, other without them. Not sure if its worth it the hessle. > BTW you can run KiTTY without opening editor with That is similar to `-load` and it behaves the same in ConEmu - the main kitty exe seems to exit asap and relaunch in either scenario. > The more apps we integration, the less code for us to maintain, only if we can fix UX problems. Not only that, but security will be better (as you can keep tools up to date no matter what is in PRM), and that way it allows for potential cross platform (you can't really pack binaries for each system...).
Author
Owner

@VShawn commented on GitHub (Jan 15, 2021):

Today I managed combine PRM with original latest kitty_portable.exe,

I create a new thread to watch KiTTY, when KiTTY gets focus I make Tab window to top by BringWindowToTop(hwnd), it successfully replaced what I have modified in KittTY_PRM. And it works great so far. So now we can

Also, not having to rebase your work on top of latest kitty is huge improvement, and will allow people to update kitty via other means such as chocolatey.

<!-- gh-comment-id:760766929 --> @VShawn commented on GitHub (Jan 15, 2021): Today I managed combine PRM with original latest [kitty_portable.exe](https://github.com/cyd01/KiTTY/releases/tag/v0.74.4.4), I create a new thread to watch KiTTY, when KiTTY gets focus I make Tab window to top by `BringWindowToTop(hwnd)`, it successfully replaced what I have modified in KittTY_PRM. And it works great so far. So now we can > Also, not having to rebase your work on top of latest kitty is huge improvement, and will allow people to update kitty via other means such as chocolatey.
Author
Owner

@majkinetor commented on GitHub (Jan 15, 2021):

Great work :)

<!-- gh-comment-id:760810982 --> @majkinetor commented on GitHub (Jan 15, 2021): Great work :)
Author
Owner

@VShawn commented on GitHub (Jun 12, 2021):

cant get the handle of winscp.

  1. when I run winscp.exe sftp://root:root@127.0.0.1:122, it open a winscp launcher and now I can get handle of the laucher by MainWindowHandle.

image

  1. then launcher start open new sftp window and close itself. now MainWindowHandle become 0, I don't know how to get the handle of the sftp window opened by the winscp launcher. Find handle by PID(FindWindowEx) returns 0 handle,

image

<!-- gh-comment-id:860013265 --> @VShawn commented on GitHub (Jun 12, 2021): cant get the handle of winscp. 1. when I run `winscp.exe sftp://root:root@127.0.0.1:122`, it open a winscp launcher and now I can get handle of the laucher by `MainWindowHandle`. ![image](https://user-images.githubusercontent.com/10143738/121768245-d937b280-cb8f-11eb-9b14-c90e48690eb4.png) 2. then launcher start open new sftp window and close itself. now `MainWindowHandle` become 0, I don't know how to get the handle of the sftp window opened by the winscp launcher. Find handle by PID(`FindWindowEx`) returns 0 handle, ![image](https://user-images.githubusercontent.com/10143738/121768509-28caae00-cb91-11eb-9aa4-c9d0201e350c.png)
Author
Owner

@majkinetor commented on GitHub (Jun 12, 2021):

Have you seen this page ?

Maybe you could try with winscp.com. If that doesn't work, I can look into getting the handle.

<!-- gh-comment-id:860104072 --> @majkinetor commented on GitHub (Jun 12, 2021): Have you seen this page ? * https://winscp.net/eng/docs/executables Maybe you could try with `winscp.com`. If that doesn't work, I can look into getting the handle.
Author
Owner

@VShawn commented on GitHub (Jun 18, 2021):

isn't winscp.com a console interface tool? we need GUI.

<!-- gh-comment-id:863822524 --> @VShawn commented on GitHub (Jun 18, 2021): isn't `winscp.com` a console interface tool? we need GUI.
Author
Owner

@majkinetor commented on GitHub (Jun 18, 2021):

OK. Will check it out

<!-- gh-comment-id:864077075 --> @majkinetor commented on GitHub (Jun 18, 2021): OK. Will check it out
Author
Owner

@VShawn commented on GitHub (Jun 23, 2021):

I've made some progress on integrate winscp.exe

image

<!-- gh-comment-id:866696009 --> @VShawn commented on GitHub (Jun 23, 2021): I've made some progress on integrate winscp.exe ![image](https://user-images.githubusercontent.com/10143738/123076082-6100a500-d44b-11eb-8520-0de50dd62757.png)
Author
Owner

@majkinetor commented on GitHub (Jun 23, 2021):

Awesome mate.

<!-- gh-comment-id:866699389 --> @majkinetor commented on GitHub (Jun 23, 2021): Awesome mate.
Author
Owner

@majkinetor commented on GitHub (Jun 23, 2021):

Do you have any plans on bundling it or using the system one ?

<!-- gh-comment-id:866699858 --> @majkinetor commented on GitHub (Jun 23, 2021): Do you have any plans on bundling it or using the system one ?
Author
Owner

@VShawn commented on GitHub (Jun 23, 2021):

Not now, I‘d like to bundle it after we port to .Net5 (or after a refactoring).

<!-- gh-comment-id:866738696 --> @VShawn commented on GitHub (Jun 23, 2021): Not now, I‘d like to bundle it after we port to .Net5 (or after a refactoring).
Author
Owner

@majkinetor commented on GitHub (Jun 23, 2021):

You talk about winscp right ? Not .net itself ?

If so, how do you find winscp ? On PATH or via config or ... ?

<!-- gh-comment-id:866739644 --> @majkinetor commented on GitHub (Jun 23, 2021): You talk about winscp right ? Not .net itself ? If so, how do you find winscp ? On PATH or via config or ... ?
Author
Owner

@VShawn commented on GitHub (Jun 23, 2021):

sorry I misunderstood

I‘d like to bundle it after we port to .Net5 (or after a refactoring).

using the path C:\Program Files (x86)\WinSCP\WinSCP.exe default, if WinSCP.exe not existed, then turn to the current ftp manager. User can custom the path too.

<!-- gh-comment-id:866742940 --> @VShawn commented on GitHub (Jun 23, 2021): sorry I misunderstood > I‘d like to bundle it after we port to .Net5 (or after a refactoring). using the path `C:\Program Files (x86)\WinSCP\WinSCP.exe` default, if WinSCP.exe not existed, then turn to the current ftp manager. User can custom the path too.
Author
Owner

@majkinetor commented on GitHub (Jun 23, 2021):

using the path C:\Program Files (x86)\WinSCP\WinSCP.exe

FYI, that path wont work on x32 bit windows, and wont work if user customized folders.

I would use the following approach instead:

  1. Check user customized path (via config for example)
  2. Check if winscp.exe is on PATH - (Get-Command winscp -ErrorAction 0).Path
  3. Check registry: (Get-UninstallRegistryKey -SoftwareName 'WinScp *').InstallLocation (not native PowerShell function, see here

The above approach will make it work always.

<!-- gh-comment-id:866748735 --> @majkinetor commented on GitHub (Jun 23, 2021): > using the path C:\Program Files (x86)\WinSCP\WinSCP.exe FYI, that path wont work on x32 bit windows, and wont work if user customized folders. I would use the following approach instead: 1. Check user customized path (via config for example) 1. Check if winscp.exe is on PATH - `(Get-Command winscp -ErrorAction 0).Path` 2. Check registry: `(Get-UninstallRegistryKey -SoftwareName 'WinScp *').InstallLocation` (not native PowerShell function, see [here](https://github.com/chocolatey-community/chocolatey-coreteampackages/blob/master/extensions/chocolatey-core.extension/extensions/Get-UninstallRegistryKey.ps1) The above approach will make it work always.
Author
Owner

@VShawn commented on GitHub (Jun 25, 2021):

With a permanent timer

There are still many things.You know Winscp first opens the launcher and then the main interface. So I using a timer to detect the main form (MainWindowHandle) of the progress , and once the main form changes, I will embed the new main form into my window. This worked well before I opened the about of WinSCP. Once I opened about form (or other forms of winscp), the whole program would get stuck for a while, and then I could do nothing to the WinSCP.

1

Without a permanent timer

After that, I changed my mind and detect the main window only within 5s after WinSCP opening. Everything works great with my LAN ftp, but this must ensure:

  1. WinSCP completes the connection within 5 seconds;
  2. The user cannot open the about window within 5 seconds.

We cannot guarantee these.

And if user gives a wrong password, WinSCP return a password dialog, main interface of winscp will come after this dialog:

image

But without a permanent timer we can never get the handle of winscp main interface 5 seconds later after process start.

The above experiences are quite unsatisfactory.

This does not consider other APPs. If an app keeps updating its main window, we will be unable to do anything about it.

<!-- gh-comment-id:868177751 --> @VShawn commented on GitHub (Jun 25, 2021): # With a permanent timer There are still many things.You know Winscp first opens the launcher and then the main interface. So I using a timer to detect the main form (`MainWindowHandle`) of the progress , and once the main form changes, I will embed the new main form into my window. This worked well before I opened the `about` of WinSCP. Once I opened about form (or other forms of winscp), the whole program would get stuck for a while, and then I could do nothing to the WinSCP. ![1](https://user-images.githubusercontent.com/10143738/123364045-5149a380-d5a6-11eb-99ed-2194db6e5f54.gif) # Without a permanent timer After that, I changed my mind and detect the main window only within 5s after WinSCP opening. Everything works great with my LAN ftp, but this must ensure: 1. WinSCP completes the connection within 5 seconds; 2. The user cannot open the about window within 5 seconds. We cannot guarantee these. And if user gives a wrong password, WinSCP return a password dialog, main interface of winscp will come after this dialog: ![image](https://user-images.githubusercontent.com/10143738/123365322-a8507800-d5a8-11eb-8b04-7cbe8d0fd5a5.png) But without a permanent timer we can never get the handle of winscp main interface 5 seconds later after process start. The above experiences are quite unsatisfactory. This does not consider other APPs. If an app keeps updating its main window, we will be unable to do anything about it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/1Remote#1003
No description provided.