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

Author Message
jameslx

Guest


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.
Advertisements
jameslx

Guest


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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
jameslx wrote:
when a new session is started to an open WinSCP instance

What does this mean?

Quote:
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

Guest


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

Quote:
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.

Quote:
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).
jameslx

Guest


Did not answer correctly the window problems, I meant "The main window of an existing WinSCP instance".
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Thanks for your answer.

When does it resize? Before an authentication or after?

Quote:
The login window is the same size as always.

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

Guest


prikryl 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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
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

Guest


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

Code:
@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: http://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

Code:
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)

Code:
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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
This bug has been added to the tracker:
http://winscp.net/tracker/show_bug.cgi?id=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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License