Search code examples
batch-filecmdwinscp

Pre populating host, username, and password for WinSCP login using .cmd file


I have created a .cmd file that allows the user to select a number that corresponds to a different set of login credentials for WinSCP thus eliminating the need to memorize login credentials for WinSCP. In my .cmd file I have set host, username, and password according to the following:

SET UID=exampleusername     
SET PWD=examplepassword
SET HOST=examplehost

I then proceed to call WinSCP using

start WinSCP.exe 

This opens the login interface:

enter image description here

The WinSCP interface is called correctly but I am having issues coding in my .cmd file to populate the Host Name, User name, and Password fields using the variables defined in my .cmd file.


Solution

  • You cannot populate the WinSCP login dialog from a command-line.

    All you can do is to have WinSCP open the session directly by calling it like:

    start WinSCP.exe sftp://%UID%:%PWD%@%HOST%/
    

    References:


    Anyway, I do not see why you implement batch-file menu for opening sessions on WinSCP. Did you consider pre-configuring stored sites for WinSCP instead?


    Btw, you are using some really ancient version of WinSCP (5 years old at least). You need to upgrade urgently.