Command-line parameter in scripting is deprecated

Advertisement

navilor
Joined:
Posts:
10

Command-line parameter in scripting is deprecated

Hello,

I just upgraded to the newest version of WinSCP (WinSCP Version 5.5.3 (Build 4214)) and am now getting the following warning:
Opening session using command-line parameter in scripting is deprecated. Use 'open' command instead.
I went to your history page here:
https://winscp.net/eng/docs/history

When I went there I noticed the following information:
Before opening session using command-line parameter in scripting, warning is printed, that this is deprecated function.
I apologize but that doesn't make sense for me right now. I hope that you can provide clarification.

My setup is as follows:
  1. I have a batch file that has the following inside of it:
    "C:\Program Files (x86)\WinSCP\winscp.com" /script="C:\Users\kevin\Desktop\Utils\winscpbatchfile.txt" /log=C:\Users\Kevin\Desktop\Utils\FreeNASSyncLogs\FreeNAS-%date:~-4,4%-%date:~4,2%-%date:~-7,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%-%time:~9,2%.log
  2. The "winscpbatchfile.txt" that is used above has the following in it:
    open sftp://usernameremoved:passwordremoved@freenas
     
    option batch continue
    option transfer binary
    option confirm off
I then have multiple sections in the text file to back up specific locations on my multiple hard drives. Below is just one:
lcd "C:\Users\kevin\Documents"
cd /mnt/share/kevin/users/kevin/Documents
synchronize remote -mirror -delete -nopreservetime -filemask=|"*.tmp; C:\Users\kevin\Documents\My Music\; C:\Users\kevin\Documents\My Pictures\; C:\Users\kevin\Documents\My Videos\;"
I did not notice any changes on this page:
https://winscp.net/eng/docs/scripting
Or this page:
https://winscp.net/eng/docs/commandline

Obviously I missed something in your documentation. Can you please provide a clue for the clueless here?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
42,165
Location:
Prague, Czechia

Re: Command-line parameter in scripting is deprecated

Your winscp.com command line should generally not produce this warning.

Unless your %date% and %time% magic is wrong and resolve in some parts to a string with spaces. I cannot verify this as I do not know in what locale you run the command. Note that %date% and %time% are locale-specific, so may not be reliable.

If this does not help, please attach your log file.

Reply with quote

navilor
Joined:
Posts:
10

Re: Command-line parameter in scripting is deprecated

That it is. Thank you for the pointer on that. Putting the log file and path in quotes resolved the issue.
"C:\Users\Kevin\Desktop\Utils\FreeNASSyncLogs\FreeNAS-%date:~-4,4%-%date:~4,2%-%date:~7,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%-%time:~9,2%.log"
This was a problem that had plagued me for a while which appeared to be random in nature. The problem was that a space was added in one or more of the time sections. This happens as my instance of Windows 7 64bit will always use "short time" on the command line. I have yet to find a way to force "long time" out on the command line even when parsing this thread:
Hidden features of Windows batch files

Reply with quote

stduser
Guest

Opening session using command-line parameter is deprecated

Hi, I am having the same issue with WinSCP 5.4.4, with the VBA shell command
Call Shell("C:\Program Files (x86)\WinSCP\winscp.com / script = ""C:\Users\xxxxxx\Documents\Test Library\ConnectCell13.txt"" ")
I get the message
Opening session using command-line parameter in scripting is deprecated. Use 'open' command instead.
The script is pretty simple:
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
 
# Force binary mode transfer
option transfer binary
 
open scp://user:passwd@cell13
 
cd /SPARE_DISK/datalog
 
get LibrChgLogCell13access.csv 
 
# Exit WinSCP
exit
I don't think I could have the option of upgrading the WinSCP version.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
42,165
Location:
Prague, Czechia

Re: Opening session using command-line parameter is deprecated

@stduser: You have spacing and quoting all wrong. It should be:
Call Shell("""C:\Program Files (x86)\WinSCP\winscp.com"" /script=""C:\Users\xxxxxx\Documents\Test Library\ConnectCell13.txt""")

Reply with quote

Advertisement

You can post new topics in this forum