Topic "Using WinSCP from portable device where drive letter changes"

Author Message
KevDog

Guest


In the spirit of portable thunderbird and portable mozilla, Im trying to run winscp strictly from a USB jumpdrive (trying to make it truly portable). Im storing all the configuration settings in a winscp.ini file located on the jump drive.

My problem, is that when using the jump drive on different computers, I am never able to predict what drive letter will be alloted to the jump drive. Winscp stores its configurations according to absolute paths. For example here is what I pulled out of the winscp374.ini file:
PuttyPath=E:%5Cputty%5Cputty.exe

What I want putty to do is to store the settings according to relative paths. I would prefer for example if the statement above read as follows:
Putty Path = .%5Cputy%5Cputty.exe (or something similar).

I noticed that putty also stores its data in the registry under the HKCU branch with absolute paths. In the putty help manual, they suggested a workaround with batch files that would write and then delete the registry settings. My problem with their suggestion is that they referenced a needed reg file called PUTTYRND.REG, that contained the following.

[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY]

"RandSeedFile"="a:\\putty.rnd"

Again an absolute path is mentioned. I know in order to write to the registry absolute paths are needed. Does anyone know a way, preferable through a batch file, or I guess through a c executable, that could return the root drive, and then make it possible to reconstruct the above statements with the variable returned?

Thanks
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
You can choose one drive letter that is free on all computers and use 'subst' command to make it alias to your USB drive.
_________________
Martin Prikryl
KevDog

Guest


I suppose use of the SUBST command is an option, however that is really not the most elegant solution. Im in the middle of writing a c program write now that will change the winscp.ini file dynamically based on discovery of the current drive letter. Im having a small problem trying to find a pattern match algorithm however, that allows me to fish out the correct options that need changing. Do you have any suggestions?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
I have not other suggestion. Just that I have tried that using relative path to Putty is no problem for WinSCP. I have also found that WinSCP is having some problem storing the random seed file at all, I'll check it later.
_________________
Martin Prikryl
KevDog

Guest


In the spirit of true portability, Ive managed to make small modifications to the way both putty and winscp startup, however I need just a word or advice from the program author.

Im managed to create a winscp_portable.exe that basically first detects the drive letter from where the program is being run, and then parses the winscp.ini file in order to change the entries with the appropriate drive letter. Martin, I need to know from you just a few things: The only entries that I see in the ini file that are drive letter dependent are RandomSeedFile, Puttypath, and PublicKeyFile. I was wondering if you know of any more??? These basically are the only entries modified in the winscp.ini file by program.

Because winscp is dependent on putty, I also was able to make a putty_portable.exe frontend. Because putty stores its values in the registry under HKCU rather than in a .ini file, the frontend basically imports registry keys into the registry at the start of the program, and then exports the keys at the conclusion, and then deletes the registry keys. This way sessions can be stored and actually settings can be saved on used on a variety of different machines. The idea was inspired by a section in the putty.hlp file.

Im not sure if any one else is interested in testing these two frontends, however they truly make winscp and putty truly portable and capable of being run from a USB jump drive (or other media) where the actual drive letter is subject to change between computers or different ports on the same machine.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
KevDog wrote:
then parses the winscp.ini file in order to change the entries with the appropriate drive letter

Well, again: I have tryied it and at least in case of Puttypath, WinSCP can handle relative paths. Unless I've missed something.

Quote:
The only entries that I see in the ini file that are drive letter dependent are RandomSeedFile, Puttypath, and PublicKeyFile.

Depends on what you need from it. There is also ExternalEditor and maybe bookmarks.
_________________
Martin Prikryl
Guest




I made it like this, and it works:

WEB -> this folder contains the mirror of the files to update
WINSCP -> this contains WinSCP3.exe, WinSCP3.ini, WinSCP3.com, winscp.RND, scpcomd.txt
update.cmd -> a batch file to launch the update process.


update.cmd:
Code:
@echo OFF
cd winscp
winscp3 /console /script=scpcomd.txt
echo.
echo.
echo Update completed.
echo.
echo Dear user,
pause



scpcomd.txt:
Code:
option batch on
option confirm off
option transfer automatic
option synchdelete on
open user:pass@my.server.com:22
synchronize remote .\..\Web /home
close
exit


This works well in any case, from any drive letter and from any sub-foler, because it uses only relative paths.
Note in
Code:
synchronize remote .\..\Web /home
the .\ changes to the current folder, the ..\ changes to parent folder.
robi
[View user's profile]

Joined: 2005-12-12
Posts: 4
it works!
Congrats
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