Topic "Unable to run winscp script from Java App"

Author Message


Unable to run winscp script from Java App code's process runtime.exec(cmd)

=> Application just hangs and does not execute the script.
(This same script runs from the command line successfully without error.)

I am using the latest WinSCP v4.2.3
cmd =
c:\program files\winscp3\ /script=scriptFile.txt /parameter \\path_to_remote_file\filename /log=logfile.xml

scriptFile.txt file =
option batch abort
option confirm off
open user:pswd@server
cd remote_path
option transfer binary
put -nopermissions %1%

I have also tried this command in the Java App without the path as: /script=scriptfile.txt /parameter \\path_to_remote_file /log=logfile.xml
(My System Env variable PATH includes c:\program files\winscp3\ )
==> still hangs Java App

I have also tried this command in the Java App using winscp.exe command instead:
c:\program files\winscp3\winscp.exe /console /script=scriptFile.txt /parameter \\path_to_remote_file\filename /log=logfile.xml
==> Java App runs the command but the Winscp GUI display as if no script was provided.

Any suggestions on getting this to work via the Java App?

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
Please post a full log file showing the problem.

To generate log file, enable logging, log in to your server and do the operation and only the operation that causes the error. For posting extensive logs you may use pastebin or similar application. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.
Martin Prikryl
[View user's profile]

Joined: 2009-09-10
Posts: 1
martin wrote:
Please post a full log file showing the problem.

I have used logs on the command line with success but not from the Java App.
The WINSCP command is not working from the Java App and therefore no log is generated. It seems that only the command itself is recognized by the app and not the rest of the line of information including the script and logfile.
Has anyone else been able to run this tool from a Java App?



Sorry for rising up such old post, but just in case if somebody else face this problem (as I did)...
I've got WinSCP runnig with /script parameter from Java this way:

Runtime.getRuntime().exec("cmd /c <full WinSCP file name> /script=<script filename>");

If I haven't used "cmd /c" script wasn't executed.
May be it will help somebody.

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License