Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Site list does not update / window size always resets / open same session

This bug has been added to the tracker:
https://winscp.net/tracker/1368

Can you send me an email, so I can send you back a development version of WinSCP for testing?

You will find my address (if you log in) in my forum profile.
jameslx

I have set a custom uri handler "caesar://" and i use it as a shortcut to open heidisql, winscp, putty and setup quick tunnels from a web page (a control panel). However, the same error can be produced (at least on my computer) just by accessing a .bat file

@echo off

mode con: cols=100 lines=10
setlocal enableextensions disabledelayedexpansion
echo "CAESAR URI handler has started..."

:: winscp         - caesar://sftp:88.88.88.88:22:root:null:null:null:null/yourpassword/null/null/#etc#lighttpd#/

:: parse the uri parameters
for /f "tokens=1 delims=:" %%C in ("%line%") do set "type=%%C"
for /f "tokens=2 delims=:" %%C in ("%line%") do set "sship=%%C"
for /f "tokens=3 delims=:" %%C in ("%line%") do set "sshport=%%C"
for /f "tokens=4 delims=:" %%C in ("%line%") do set "sshuser=%%C"
for /f "tokens=2 delims=/" %%C in ("%line%") do set "sshpass=%%C"
for /f "tokens=3 delims=/" %%C in ("%line%") do set "sqluser=%%C"
for /f "tokens=4 delims=/" %%C in ("%line%") do set "sqlpass=%%C"
for /f "tokens=5 delims=/" %%C in ("%line%") do set "sftpdir=%%C"
for /f "tokens=5 delims=:" %%C in ("%line%") do set "remoteip=%%C"
for /f "tokens=6 delims=:" %%C in ("%line%") do set "remoteport=%%C"
for /f "tokens=7 delims=:" %%C in ("%line%") do set "localport=%%C"

:: sftp directory
set sftpdir=%sftpdir:#=/%
if "%sftpdir%"=="" set sftpdir="/%sshuser%"
if "%sftpdir%"=="null" set sftpdir="/%sshuser%"
:: let's just user's home directory (winscp does not reload it's sites database if the application is active and registry changes)
set sftpdir="/%sshuser%"

:: create a popup message file
@echo Set objArgs = WScript.Arguments > %AppData%\\caesarurimsg.vbs
@echo messageText = objArgs(0) >> %AppData%\\caesarurimsg.vbs
@echo MsgBox messageText,0,"Caesar URI Notification" >> %AppData%\\caesarurimsg.vbs

:: check if winscp is installed
if exist "C:\Progra~1\WinSCP\WinSCP.exe" set apploc_winscp=C:\Progra~1\WinSCP\WinSCP.exe
if exist "C:\Progra~2\WinSCP\WinSCP.exe" set apploc_winscp=C:\Progra~2\WinSCP\WinSCP.exe
if "%apploc_winscp%"=="" (
   cmd /c cscript %AppData%\\caesarurimsg.vbs "Could not find WinSCP.exe in the default location. If it it not installed, - install it, if it is - check the script location inside %SystemRoot%\caesaruri.bat."
   exit
)

:: add registry values for winscp (if they do not already exist)
:: reference here: https://winscp.net/eng/docs/custom_distribution#distributing_passwords
if "%type%"=="sftp" set create_sftp_reg=1
set "winscpkey=HKEY_CURRENT_USER\Software\Martin Prikryl\WinSCP 2\Sessions\%sessionname%"
if defined create_sftp_reg (
   echo "Preparing WinSCP..."
   REG QUERY "%winscpkey%">nul && (
      echo "- Session has already been created before..."
   ) || (
      echo "- Creating a new session..."
      REG ADD "%winscpkey%" /f /v "HostName" /t REG_SZ /d "%sship%" > NUL
      REG ADD "%winscpkey%" /f /v "Username" /t REG_SZ /d "%sshuser%" > NUL
      REG ADD "%winscpkey%" /f /v "PortNumber" /t REG_DWORD /d "%sshport%" > NUL
      REG ADD "%winscpkey%" /f /v "PasswordPlain" /t REG_SZ /d "%sshpass%" > NUL
   )
)

:: open a winscp connection (to solve a "Host not found" (tested up to v5.8) bug when creating new sessions - when a new session is created and error occurs, go to "Session>Sites>Site Manager" (a new dialog will open), close the dialog - problem will not occur for the same session next time)
if "%type%"=="sftp" (
   echo "- Opening WinSCP..."
   if not "%sftpdir%"=="" (
      REG ADD "%winscpkey%" /f /v "RemoteDirectory" /t REG_SZ /d "%sftpdir%" > NUL
   )
   %apploc_winscp% "%sessionname%"
)

:: just in case
exit


The script above can be called using the code below via cmd.exe

hstart.exe /UAC "caesaruri.bat %1"


However, I use the custom uri handler to call it, it can be set up with .reg (contents below)

Windows Registry Editor Version 5.00


[HKEY_CLASSES_ROOT\CAESAR]
@="url:caesar protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\CAESAR\shell]

[HKEY_CLASSES_ROOT\CAESAR\shell\open]

[HKEY_CLASSES_ROOT\CAESAR\shell\open\command]
@="hstart.exe /UAC \"caesaruri.bat %1\""


NOTE: I minimized the .bat script to only show winscp, I did a fast review, but there might be some bugs/missing code, but I think that the most important parts can be understood without even executing the code.
martin

jameslx wrote:

but the problem with "host does not exist" is still there.

What are the exact steps to reproduce this?
Do you create a new site in a separate instance, close it, and then you open the new site in the existing instance from a command-line/desktop shortcut?
jameslx

martin wrote:

When does it resize? Before an authentication or after?


It resizes before the authentication window (yes, there is no login window, no inputs occur during the connection process).

However, at the moment, the problem somehow disappeared, I did not upgrade the application, did not even turn it off, it somehow fixed itself (at best, I opened and closed some sessions). Do not really know why this happened, but the problem with "host does not exist" is still there.
martin

Thanks for your answer.

When does it resize? Before an authentication or after?

The login window is the same size as always.

But there should be no Login window, right? Or do you mean the Authentication window?
https://winscp.net/eng/docs/ui_authenticate
jameslx

Did not answer correctly the window problems, I meant "The main window of an existing WinSCP instance".
jameslx

Sorry for the late reply, I forgot about the thread...

when a new session is started to an open WinSCP instance


I meant when WinSCP is already open (a process is running / WinSCP.exe is visible in Task Manager).
When the application is not active/not open - it works, no errors occur, session is created.

Which window? Login dialog? The main window of an existing WinSCP instance?


The whole window is resized. The login window is the same size as always.
If it makes a difference - I create a password entry in the registry, so no password prompt occurs while connecting (if the password correct of course).

I use v5.7.5 (currently the latest one).
martin

Re: Site list does not update / window size always resets / open same session

jameslx wrote:

when a new session is started to an open WinSCP instance

What does this mean?

BUG #2 - I do not have a logical explanation for this. When I do > C:\Progra~2\WinSCP\WinSCP.exe "SESSION NAME" > the WinSCP window always resets to a very uncomfortable size (600x600 maybe, it's hard to tell on a 18" screen)

Which window? Login dialog? The main window of an existing WinSCP instance?
jameslx

Forgot to add - Is it possible to somehow check if the session is already open pragmatically (or in some other way) and just not open a new tab if the session is already open?
jameslx

Site list does not update / window size always resets / open same session

Hello,

STORY - I programmed myself a quick Windows batch based script which creates new/modifies existing WinSCP sessions in registry (or with /ini options - really does not make any difference).

BUG #1 - The problem is that when a new session is started to an open WinSCP instance I always get "Host XXXX does not exist" (new instances work). The problem is that the application does not update it's sessions list automatically. I can trigger it myself by going to "Session>Sites>Site Manager", but I shouldn't really need to do that - the program should do it.

BUG #2 - I do not have a logical explanation for this. When I do > C:\Progra~2\WinSCP\WinSCP.exe "SESSION NAME" > the WinSCP window always resets to a very uncomfortable size (600x600 maybe, it's hard to tell on a 18" screen)

Waiting for any possible resolutions.

Regards.