This is an old revision of the document!
Custom Distribution
This chapter includes hints for those who want to prepare custom distribution of WinSCP with own configuration (typically preconfigured sessions).
- Creating Custom Installer
- Preconfigured Session
- Using INI File as Configuration Storage
- Distributing Passwords
- Embedded Settings
- Licence
Advertisement
Creating Custom Installer
WinSCP uses Inno Setup as installer. The most simple InnoSetup script for WinSCP may look like the one below. For full WinSCP install script see file release/winscpsetup.iss
in the source code.
[Setup] ; Name of the application AppName=WinSCP3 (provided by Some Company) ; Name of the application including version AppVerName=WinSCP 3.7.5 ; Installation directory (can be changed by user) DefaultDirName={pf}\WinSCP3 ; Start menu group name DefaultGroupName=WinSCP3 (provided by Some Company) ; Not to allow installation while WinSCP is running AppMutex=WinSCP [Files] ; Install WinSCP itself Source: "WinSCP3.exe"; DestDir: "{app}"; \ Flags: ignoreversion ; It is recommended (especially for not experienced users) to install ; drag&drop shell extension Source: "DragExt.dll"; DestDir: "{app}"; \ Flags: ignoreversion regserver restartreplace restartreplace uninsrestartdelete [Icons] ; Start menu icon Name: "{group}\WinSCP"; Filename: "{app}\WinSCP3.exe" ; Desktop icon Name: "{userdesktop}\WinSCP3"; Filename: "{app}\WinSCP3.exe" [Registry] #define RegistryKey "Software\Martin Prikryl\WinSCP 2" ; Make Explorer-like interface initial setting ; (recommended especially for not experienced users) ; Remove or use value 0 for Norton Commander interface Root: HKCU; SubKey: "{#RegistryKey}\Configuration\Interface"; ValueType: dword; \ ValueName: "Interface"; ValueData: 1 ; Enable using of drag&drop shell extension ; (and make sure it is disabled again when the extension is uninstalled) Root: HKCU; SubKey: "{#RegistryKey}\Configuration\Interface"; ValueType: dword; \ ValueName: "DDExtEnabled"; ValueData: 1; \ Flags: uninsdeletevalue [Run] ; Offer starting WinSCP after installation Filename: "{app}\WinSCP3.exe"; Description: "Launch &WinSCP"; \ Flags: nowait postinstall skipifsilent [UninstallRun] ; Offer configuration cleanup on uninstallation Filename: "{app}\WinSCP3.exe"; Parameters: "/UninstallCleanup"; \ RunOnceId: "UninstallCleanup"
Advertisement
Save the script into file (e.g. winscpsetup.iss
), put files WinSCP3.exe
and DragExt.dll
to the same directory and run InnoSetup compiler:
iscc winscpsetup.iss
Preconfigured Session
You may have the installer pre-configure stored sessions, to make it easier for your users to connect to your server.
The easiest way is to configure the session using GUI and then check the configuration storage to see how WinSCP stores the session settings. Then add corresponding commands to the installer script.
Simple example of “Server” session configuration, including hostname and username only, is shown below. You can also use hidden option Special
to prevent user from accidentally deleting or modifing the session. Such session will also be highlighted in session list.
[Registry] #define RegistryKey "Software\Martin Prikryl\WinSCP 2" ; Configure hostname/username Root: HKCU; SubKey: "{#RegistryKey}\Sessions\Server"; ValueType: string; \ ValueName: "HostName"; ValueData: "example.com" Root: HKCU; SubKey: "{#RegistryKey}\Sessions\Server"; ValueType: string; \ ValueName: "UserName"; ValueData: "customer" ; Prevent user from accidentally deleting or modifing the session Root: HKCU; SubKey: "{#RegistryKey}\Sessions\Server"; ValueType: dword; \ ValueName: "Special"; ValueData: 1
Using INI File as Configuration Storage
Instead of modifing the registry from install script your can make the installer create configuration INI file.
You can also have the installer install the embeded INI file, like:
[Configuration\Interface] Interface=1 [Sessions\Server] HostName=example.com UserName=customer Special=1
Distributing Passwords
While not recommended, you can distribute even session passwords. By default the password needs to be stored in encrypted form to option ‘Password’. You can store the password from GUI to get the correct encrypted form (note that key for encryption in hostname and username, so the encrypted password cannot be misused for other session).
Advertisement
If you need to store the password in plain-text, use session option ‘PasswordPlain’, instead of ‘Password’. Note that WinSCP will, if possible, replace the ‘PasswordPlain’ with equivalent ‘Password’ option on the first start-up.
Embedded Settings
As alternative to own installer you can directly embed session settings to WinSCP executable.
You can do it by inserting INI file with session settings to RCData
resource named “WINSCP_SESSION”.
[Sessions\Server] HostName=example.com UserName=customer
When WinSCP finds such resource it loads the session list from it instead of configured storage. In addition it automatically starts the first session in the list, unless overriden by specifing name of another session on command line. Note that general configuration options will be ignored, when present in the INI file.
You can also embed private key to be used for authentication to RCData
resource named “WINSCP_KEY”. WinSCP will automatically try to use it for authentication unless session has its own key configured.
To embed RCData
resource you can use any resource editor, for example Resource Hacker.
Licence
When creating custom distribution of WinSCP, please bear in mind that you need to follow GPL licence.