Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Windows Server Task Scheduler gives 0x1 as Last Run Result

I wanted to see an console output of winscp.com or of your batch file. Not a log file (well that's useful too).

The log you posted is for manual run or scheduled run? Also there are two runs in the log, one incomplete followed by one complete. Interesting is that the complete run started before the incomplete run finished. What may indicate parallel runs of WinSCP logging into a same log and possibly accessing also other files at the same time. That can be a cause of your problem.
riceric

Re: Windows Server Task Scheduler gives 0x1 as Last Run Result

@martin: Yes, I tried doing this without change in result: 1) Manually running batch script works and outputs log 2) Running batch script from Task Scheduler results in 0x1 from WinSCP (remaining batch script functions execute correctly)

Here is the batch file:
@echo off
set rxfolder=C:\Localdirectory
set filetypes=*.xml
set backupcmd=move /y
 
echo %date% %time% >> foc-autotask.log 2>&1
echo ### SFTP files... >> foc-autotask.log 2>&1
"C:\Program Files (x86)\WinSCP\WinSCP.com" /log=%rxfolder%\!T!S.log /command "option batch abort" "option confirm off" "open sftp://<unm>:<pwd>@<ftp-server>" "put C:\Localdirectory\*.xml /remotedirectory/" "exit"
 
echo ### Backing up Rx orders... >> foc-autotask.log 2>&1
%backupcmd% "%rxfolder%\%filetypes%" "%rxfolder%\backup\"
 
echo Backup Complete!------------------- >> foc-autotask.log 2>&1
 
exit

Here is the resulting log:
. 2014-02-28 10:57:57.689 --------------------------------------------------------------------------
. 2014-02-28 10:57:57.689 WinSCP Version 5.5.1 (Build 3970) (OS 6.1.7601 Service Pack 1 - Windows Server 2008 R2 Standard)
. 2014-02-28 10:57:57.689 Configuration: C:\Program Files (x86)\WinSCP\WinSCP.ini
. 2014-02-28 10:57:57.689 Local account: <windows-admin>
. 2014-02-28 10:57:57.689 Working directory: C:\RO\OrderXML
. 2014-02-28 10:57:57.689 Process ID: 7524
. 2014-02-28 10:57:57.689 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console=551 /consoleinstance=_4504_607 "/log=C:\RO\OrderXML\!T!S.log" "/command" "option batch abort" "option confirm off" "open sftp://<unm>:<pwd>@<ftp-server>" "put C:\LocalDirectory\*.xml /remotedirectory/" "exit"
. 2014-02-28 10:57:57.689 Time zone: Current: GMT-6, Standard: GMT-6, DST: GMT-5, DST Start: 3/9/2014, DST End: 11/2/2014
. 2014-02-28 10:57:57.689 Login time: Friday, February 28, 2014 10:57:57 AM
. 2014-02-28 10:57:57.689 --------------------------------------------------------------------------
. 2014-02-28 10:57:57.689 Script: Retrospectivelly logging previous script records:
> 2014-02-28 10:57:57.689 Script: option batch abort
< 2014-02-28 10:57:57.689 Script: batch           abort     
> 2014-02-28 10:57:57.689 Script: option confirm off
< 2014-02-28 10:57:57.689 Script: confirm         off       
> 2014-02-28 10:57:57.689 Script: open sftp://<unm>***@<ftp-server>
. 2014-02-28 10:57:57.689 --------------------------------------------------------------------------
. 2014-02-28 10:57:57.689 Session name: <unm>@<ftp-server> (Ad-Hoc site)
. 2014-02-28 10:57:57.689 Host name: <ftp-server> (Port: 22)
. 2014-02-28 10:57:57.689 User name: <unm> (Password: Yes, Key file: No)
. 2014-02-28 10:57:57.689 Tunnel: No
. 2014-02-28 10:57:57.689 Transfer Protocol: SFTP
. 2014-02-28 10:57:57.689 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2014-02-28 10:57:57.689 Proxy: none
. 2014-02-28 10:57:57.689 Send buffer: 262144
. 2014-02-28 10:57:57.689 SSH protocol version: 2; Compression: No
. 2014-02-28 10:57:57.689 Bypass authentication: No
. 2014-02-28 10:57:57.689 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2014-02-28 10:57:57.689 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2014-02-28 10:57:57.689 SSH Bugs: A,A,A,A,A,A,A,A,A,A
. 2014-02-28 10:57:57.689 Simple channel: Yes
. 2014-02-28 10:57:57.689 Return code variable: Autodetect; Lookup user groups: A
. 2014-02-28 10:57:57.689 Shell: default
. 2014-02-28 10:57:57.689 EOL: 0, UTF: 2
. 2014-02-28 10:57:57.689 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2014-02-28 10:57:57.689 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2014-02-28 10:57:57.689 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2014-02-28 10:57:57.689 Cache directory changes: Yes, Permanent: Yes
. 2014-02-28 10:57:57.689 DST mode: 1; Timezone offset: 0h 0m
. 2014-02-28 10:57:57.689 --------------------------------------------------------------------------
. 2014-02-28 10:57:57.689 Looking up host "<ftp-server>"
. 2014-02-28 10:57:57.689 Connecting to <ftp-server> port 22
. 2014-02-28 10:57:57.736 Server version: SSH-2.0-OpenSSH_4.3
. 2014-02-28 10:57:57.736 Using SSH protocol version 2
. 2014-02-28 10:57:57.736 We claim version: SSH-2.0-WinSCP_release_5.5.1
. 2014-02-28 10:57:57.751 Doing Diffie-Hellman group exchange
. 2014-02-28 10:57:57.829 Doing Diffie-Hellman key exchange with hash SHA-1
. 2014-02-28 10:57:58.485 Verifying host key rsa2 *****
. 2014-02-28 10:57:58.485 Host key matches cached key
. 2014-02-28 10:57:58.485 Host key fingerprint is:
. 2014-02-28 10:57:58.485 ssh-rsa 2048 ****
. 2014-02-28 10:57:58.485 Initialised AES-256 SDCTR client->server encryption
. 2014-02-28 10:57:58.485 Initialised HMAC-SHA1 client->server MAC algorithm
. 2014-02-28 10:57:58.485 Initialised AES-256 SDCTR server->client encryption
. 2014-02-28 10:57:58.485 Initialised HMAC-SHA1 server->client MAC algorithm
! 2014-02-28 10:57:58.563 Using username "<unm>".
. 2014-02-28 10:57:58.578 Prompt (7, SSH password, , &Password: )
. 2014-02-28 10:57:58.578 Using stored password.
. 2014-02-28 10:57:58.578 Sent password
. 2014-02-28 10:57:58.594 Access granted
. 2014-02-28 10:57:58.594 Opening session as main channel
. 2014-02-28 10:57:58.609 Opened main channel
. 2014-02-28 10:57:58.719 Started a shell/command
. 2014-02-28 10:57:58.719 --------------------------------------------------------------------------
. 2014-02-28 10:57:58.719 Using SFTP protocol.
. 2014-02-28 10:57:58.719 Doing startup conversation with host.
> 2014-02-28 10:57:58.719 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2014-02-28 10:57:58.734 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2014-02-28 10:57:58.734 SFTP version 3 negotiated.
. 2014-02-28 10:57:58.734 We believe the server has signed timestamps bug
. 2014-02-28 10:57:58.734 We will use UTF-8 strings when appropriate
. 2014-02-28 10:57:58.734 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2014-02-28 10:57:58.734 Getting current directory name.
. 2014-02-28 10:57:58.734 Getting real path for '.'
> 2014-02-28 10:57:58.734 Type: SSH_FXP_REALPATH, Size: 10, Number: 16. 2014-02-28 10:57:57.689 --------------------------------------------------------------------------
. 2014-02-28 10:57:57.689 WinSCP Version 5.5.1 (Build 3970) (OS 6.1.7601 Service Pack 1 - Windows Server 2008 R2 Standard)
. 2014-02-28 10:57:57.689 Configuration: C:\Program Files (x86)\WinSCP\WinSCP.ini
. 2014-02-28 10:57:57.689 Local account: <windows-admin>
. 2014-02-28 10:57:57.689 Working directory: C:\RO\OrderXML
. 2014-02-28 10:57:57.689 Process ID: 7524
. 2014-02-28 10:57:57.689 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console=551 /consoleinstance=_4504_607 "/log=C:\RO\OrderXML\!T!S.log" "/command" "option batch abort" "option confirm off" "open sftp://<unm>:<pwd>@<ftp-server>" "put C:\LocalDirectory\*.xml /remotedirectory/" "exit"
. 2014-02-28 10:57:57.689 Time zone: Current: GMT-6, Standard: GMT-6, DST: GMT-5, DST Start: 3/9/2014, DST End: 11/2/2014
. 2014-02-28 10:57:57.689 Login time: Friday, February 28, 2014 10:57:57 AM
. 2014-02-28 10:57:57.689 --------------------------------------------------------------------------
. 2014-02-28 10:57:57.689 Script: Retrospectivelly logging previous script records:
> 2014-02-28 10:57:57.689 Script: option batch abort
< 2014-02-28 10:57:57.689 Script: batch           abort     
> 2014-02-28 10:57:57.689 Script: option confirm off
< 2014-02-28 10:57:57.689 Script: confirm         off       
> 2014-02-28 10:57:57.689 Script: open sftp://<unm>***@<ftp-server>
. 2014-02-28 10:57:57.689 --------------------------------------------------------------------------
. 2014-02-28 10:57:57.689 Session name: <unm>@<ftp-server> (Ad-Hoc site)
. 2014-02-28 10:57:57.689 Host name: <ftp-server> (Port: 22)
. 2014-02-28 10:57:57.689 User name: <unm> (Password: Yes, Key file: No)
. 2014-02-28 10:57:57.689 Tunnel: No
. 2014-02-28 10:57:57.689 Transfer Protocol: SFTP
. 2014-02-28 10:57:57.689 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2014-02-28 10:57:57.689 Proxy: none
. 2014-02-28 10:57:57.689 Send buffer: 262144
. 2014-02-28 10:57:57.689 SSH protocol version: 2; Compression: No
. 2014-02-28 10:57:57.689 Bypass authentication: No
. 2014-02-28 10:57:57.689 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2014-02-28 10:57:57.689 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2014-02-28 10:57:57.689 SSH Bugs: A,A,A,A,A,A,A,A,A,A
. 2014-02-28 10:57:57.689 Simple channel: Yes
. 2014-02-28 10:57:57.689 Return code variable: Autodetect; Lookup user groups: A
. 2014-02-28 10:57:57.689 Shell: default
. 2014-02-28 10:57:57.689 EOL: 0, UTF: 2
. 2014-02-28 10:57:57.689 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2014-02-28 10:57:57.689 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2014-02-28 10:57:57.689 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2014-02-28 10:57:57.689 Cache directory changes: Yes, Permanent: Yes
. 2014-02-28 10:57:57.689 DST mode: 1; Timezone offset: 0h 0m
. 2014-02-28 10:57:57.689 --------------------------------------------------------------------------
. 2014-02-28 10:57:57.689 Looking up host "<ftp-server>"
. 2014-02-28 10:57:57.689 Connecting to <ftp-server> port 22
. 2014-02-28 10:57:57.736 Server version: SSH-2.0-OpenSSH_4.3
. 2014-02-28 10:57:57.736 Using SSH protocol version 2
. 2014-02-28 10:57:57.736 We claim version: SSH-2.0-WinSCP_release_5.5.1
. 2014-02-28 10:57:57.751 Doing Diffie-Hellman group exchange
. 2014-02-28 10:57:57.829 Doing Diffie-Hellman key exchange with hash SHA-1
. 2014-02-28 10:57:58.485 Verifying host key rsa2 ****
. 2014-02-28 10:57:58.485 Host key matches cached key
. 2014-02-28 10:57:58.485 Host key fingerprint is:
. 2014-02-28 10:57:58.485 ssh-rsa 2048 ****
. 2014-02-28 10:57:58.485 Initialised AES-256 SDCTR client->server encryption
. 2014-02-28 10:57:58.485 Initialised HMAC-SHA1 client->server MAC algorithm
. 2014-02-28 10:57:58.485 Initialised AES-256 SDCTR server->client encryption
. 2014-02-28 10:57:58.485 Initialised HMAC-SHA1 server->client MAC algorithm
! 2014-02-28 10:57:58.563 Using username "<unm>".
. 2014-02-28 10:57:58.578 Prompt (7, SSH password, , &Password: )
. 2014-02-28 10:57:58.578 Using stored password.
. 2014-02-28 10:57:58.578 Sent password
. 2014-02-28 10:57:58.594 Access granted
. 2014-02-28 10:57:58.594 Opening session as main channel
. 2014-02-28 10:57:58.609 Opened main channel
. 2014-02-28 10:57:58.719 Started a shell/command
. 2014-02-28 10:57:58.719 --------------------------------------------------------------------------
. 2014-02-28 10:57:58.719 Using SFTP protocol.
. 2014-02-28 10:57:58.719 Doing startup conversation with host.
> 2014-02-28 10:57:58.719 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2014-02-28 10:57:58.734 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2014-02-28 10:57:58.734 SFTP version 3 negotiated.
. 2014-02-28 10:57:58.734 We believe the server has signed timestamps bug
. 2014-02-28 10:57:58.734 We will use UTF-8 strings when appropriate
. 2014-02-28 10:57:58.734 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2014-02-28 10:57:58.734 Getting current directory name.
. 2014-02-28 10:57:58.734 Getting real path for '.'
> 2014-02-28 10:57:58.734 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2014-02-28 10:57:58.750 Type: SSH_FXP_NAME, Size: 71, Number: 16
. 2014-02-28 10:57:58.750 Real path is '/remotedirectory'
. 2014-02-28 10:57:58.750 Startup conversation with host finished.
< 2014-02-28 10:57:58.750 Script: Active session: [1] <unm>@<ftp-server>
> 2014-02-28 10:57:58.750 Script: put C:\LocalDirectory\*.xml /remotedirectory/
. 2014-02-28 10:57:58.750 Copying 1 files/directories to remote directory "/remotedirectory/"
. 2014-02-28 10:57:58.750   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask:
. 2014-02-28 10:57:58.750   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM:
. 2014-02-28 10:57:58.750   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2014-02-28 10:57:58.765 File: 'C:\LocalDirectory\FC00469_0001_0001.xml' [2014-02-27T23:46:50.250Z] [6200]
. 2014-02-28 10:57:58.765 Copying "C:\LocalDirectory\FC00469_0001_0001.xml" to remote directory started.
. 2014-02-28 10:57:58.765 Binary transfer mode selected.
. 2014-02-28 10:57:58.765 Opening remote file.
> 2014-02-28 10:57:58.765 Type: SSH_FXP_OPEN, Size: 69, Number: 259
< 2014-02-28 10:57:58.781 Type: SSH_FXP_HANDLE, Size: 13, Number: 259
> 2014-02-28 10:57:58.781 Type: SSH_FXP_WRITE, Size: 4121, Number: 774
. 2014-02-28 10:57:58.781 1 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2014-02-28 10:57:58.781 Type: SSH_FXP_CLOSE, Size: 13, Number: 1284
> 2014-02-28 10:57:58.781 Type: SSH_FXP_SETSTAT, Size: 65, Number: 521
< 2014-02-28 10:57:58.812 Type: SSH_FXP_STATUS, Size: 24, Number: 774
< 2014-02-28 10:57:59.093 Type: SSH_FXP_STATUS, Size: 24, Number: 1030
< 2014-02-28 10:57:59.093 Type: SSH_FXP_STATUS, Size: 24, Number: 1284
< 2014-02-28 10:57:59.093 Status code: 0
. 2014-02-28 10:57:59.093 Preserving timestamp [2014-02-27T23:46:50.000Z]
< 2014-02-28 10:57:59.093 Type: SSH_FXP_STATUS, Size: 24, Number: 521
< 2014-02-28 10:57:59.093 Status code: 0
> 2014-02-28 10:57:59.093 Script: exit
. 2014-02-28 10:57:59.093 Script: Exit code: 0
. 2014-02-28 10:57:59.093 Closing connection.
. 2014-02-28 10:57:59.093 Sending special code: 12
. 2014-02-28 10:57:59.093 Sent EOF message
 
< 2014-02-28 10:57:58.750 Type: SSH_FXP_NAME, Size: 71, Number: 16
. 2014-02-28 10:57:58.750 Real path is '/remotedirectory'
. 2014-02-28 10:57:58.750 Startup conversation with host finished.
< 2014-02-28 10:57:58.750 Script: Active session: [1] <unm>@<ftp-server>
> 2014-02-28 10:57:58.750 Script: put C:\LocalDirectory\*.xml /remotedirectory/
. 2014-02-28 10:57:58.750 Copying 1 files/directories to remote directory "/remotedirectory/"
. 2014-02-28 10:57:58.750   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask:
. 2014-02-28 10:57:58.750   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM:
. 2014-02-28 10:57:58.750   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2014-02-28 10:57:58.765 File: 'C:\LocalDirectory\FC00469_0001_0001.xml' [2014-02-27T23:46:50.250Z] [6200]
. 2014-02-28 10:57:58.765 Copying "C:\LocalDirectory\FC00469_0001_0001.xml" to remote directory started.
. 2014-02-28 10:57:58.765 Binary transfer mode selected.
. 2014-02-28 10:57:58.765 Opening remote file.
> 2014-02-28 10:57:58.765 Type: SSH_FXP_OPEN, Size: 69, Number: 259
< 2014-02-28 10:57:58.781 Type: SSH_FXP_HANDLE, Size: 13, Number: 259
> 2014-02-28 10:57:58.781 Type: SSH_FXP_WRITE, Size: 4121, Number: 774
. 2014-02-28 10:57:58.781 1 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2014-02-28 10:57:58.781 Type: SSH_FXP_CLOSE, Size: 13, Number: 1284
> 2014-02-28 10:57:58.781 Type: SSH_FXP_SETSTAT, Size: 65, Number: 521
< 2014-02-28 10:57:58.812 Type: SSH_FXP_STATUS, Size: 24, Number: 774
< 2014-02-28 10:57:59.093 Type: SSH_FXP_STATUS, Size: 24, Number: 1030
< 2014-02-28 10:57:59.093 Type: SSH_FXP_STATUS, Size: 24, Number: 1284
< 2014-02-28 10:57:59.093 Status code: 0
. 2014-02-28 10:57:59.093 Preserving timestamp [2014-02-27T23:46:50.000Z]
< 2014-02-28 10:57:59.093 Type: SSH_FXP_STATUS, Size: 24, Number: 521
< 2014-02-28 10:57:59.093 Status code: 0
> 2014-02-28 10:57:59.093 Script: exit
. 2014-02-28 10:57:59.093 Script: Exit code: 0
. 2014-02-28 10:57:59.093 Closing connection.
. 2014-02-28 10:57:59.093 Sending special code: 12
. 2014-02-28 10:57:59.093 Sent EOF message

Thanks for your help and reply!
riceric

Re: Windows Server Task Scheduler gives 0x1 as Last Run Result

Hello, I still need help on this issue. Does anyone have any ideas for me? Any insights are greatly appreciated. Again, I am running Windows Server 2008 R2; WinSCP 5.5.1; The Task Scheduler is running the script from an account with full admin rights. I cannot figure out why Task Scheduler is showing a 0x1 returned from WinSCP.

Running the batch file manually works just fine.

Thank you in advance!
-Eric
riceric

Windows Server Task Scheduler gives 0x1 as Last Run Result

I am having a similar problem, and the FAQ above did not seem to help.

I am running Windows Server 2008 R2; WinSCP 5.5.1; The Task Scheduler is running the script from an account with full admin rights;

I wrote a batch script to use WinSCP to connect to an FTP server, copy some files, and then exit. (This used to work until recently...not sure what changed because other admins were introduced). After the local files are uploaded to the FTP server, the batch file copies them to a backup directory.

The Task Scheduler still appears to run all the batch commands, because the backup directory is always updated. However, the FTP is failing.

I turned on logging from the WinSCP client (and script) to try and capture the problem, but I only get a log file when running the batch script--not the task scheduler.

I also configured WinSCP to use the .INI file.

Here is a sample log from a batch file session:
. 2014-02-18 17:18:27.219 --------------------------------------------------------------------------
. 2014-02-18 17:18:27.219 WinSCP Version 5.5.1 (Build 3970) (OS 6.1.7601 Service Pack 1 - Windows Server 2008 R2 Standard)
. 2014-02-18 17:18:27.219 Configuration: C:\Program Files (x86)\WinSCP\WinSCP.ini
. 2014-02-18 17:18:27.219 Local account: admin
. 2014-02-18 17:18:27.219 Working directory: C:\LocalDir
. 2014-02-18 17:18:27.219 Process ID: 6448
. 2014-02-18 17:18:27.219 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe"  /log=C:\LocalDir\!T!S.log /command "option batch abort" "option confirm off" "open sftp://<unm>:<password>@<ftp-address>" "put C:\LocalDir\*.xml /remote/dir/" "exit"
. 2014-02-18 17:18:27.219 Time zone: Current: GMT-6, Standard: GMT-6, DST: GMT-5, DST Start: 3/9/2014, DST End: 11/2/2014
. 2014-02-18 17:18:27.219 Login time: Tuesday, February 18, 2014 5:18:27 PM
. 2014-02-18 17:18:27.219 --------------------------------------------------------------------------
. 2014-02-18 17:18:27.219 Script: Retrospectivelly logging previous script records:
> 2014-02-18 17:18:27.219 Script: option batch abort
< 2014-02-18 17:18:27.219 Script: batch           abort     
> 2014-02-18 17:18:27.219 Script: option confirm off
< 2014-02-18 17:18:27.219 Script: confirm         off       
> 2014-02-18 17:18:27.219 Script: open sftp://<unm>:***@<ftp-address>
. 2014-02-18 17:18:27.219 --------------------------------------------------------------------------
. 2014-02-18 17:18:27.219 Session name: <unm>@<ftp-address> (Ad-Hoc site)
. 2014-02-18 17:18:27.219 Host name: <ftp-address> (Port: 22)
. 2014-02-18 17:18:27.219 User name: <unm> (Password: Yes, Key file: No)
. 2014-02-18 17:18:27.219 Tunnel: No
. 2014-02-18 17:18:27.219 Transfer Protocol: SFTP
. 2014-02-18 17:18:27.219 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2014-02-18 17:18:27.219 Proxy: none
. 2014-02-18 17:18:27.219 Send buffer: 262144
. 2014-02-18 17:18:27.219 SSH protocol version: 2; Compression: No
. 2014-02-18 17:18:27.219 Bypass authentication: No
. 2014-02-18 17:18:27.219 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2014-02-18 17:18:27.219 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2014-02-18 17:18:27.219 SSH Bugs: A,A,A,A,A,A,A,A,A,A
. 2014-02-18 17:18:27.219 Simple channel: Yes
. 2014-02-18 17:18:27.219 Return code variable: Autodetect; Lookup user groups: A
. 2014-02-18 17:18:27.219 Shell: default
. 2014-02-18 17:18:27.219 EOL: 0, UTF: 2
. 2014-02-18 17:18:27.219 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2014-02-18 17:18:27.219 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2014-02-18 17:18:27.219 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2014-02-18 17:18:27.219 Cache directory changes: Yes, Permanent: Yes
. 2014-02-18 17:18:27.219 DST mode: 1; Timezone offset: 0h 0m
. 2014-02-18 17:18:27.219 --------------------------------------------------------------------------
. 2014-02-18 17:18:27.219 Looking up host "<ftp-address>"
. 2014-02-18 17:18:27.219 Connecting to <ftp-address> port 22
. 2014-02-18 17:18:27.266 Server version: SSH-2.0-OpenSSH_4.3
. 2014-02-18 17:18:27.266 Using SSH protocol version 2
. 2014-02-18 17:18:27.266 We claim version: SSH-2.0-WinSCP_release_5.5.1
. 2014-02-18 17:18:27.281 Doing Diffie-Hellman group exchange
. 2014-02-18 17:18:27.359 Doing Diffie-Hellman key exchange with hash SHA-1
. 2014-02-18 17:18:28.077 Verifying host key rsa2 ...
. 2014-02-18 17:18:28.077 Host key does not match cached key ...
. 2014-02-18 17:18:28.077 Host key matches cached key
. 2014-02-18 17:18:28.077 Host key fingerprint is:
. 2014-02-18 17:18:28.077 ssh-rsa 2048 e7:ff:5a:7f:d1:1a:a6:bc:12:e5:c3:d9:5a:ba:5d:8e
. 2014-02-18 17:18:28.077 Initialised AES-256 SDCTR client->server encryption
. 2014-02-18 17:18:28.077 Initialised HMAC-SHA1 client->server MAC algorithm
. 2014-02-18 17:18:28.077 Initialised AES-256 SDCTR server->client encryption
. 2014-02-18 17:18:28.077 Initialised HMAC-SHA1 server->client MAC algorithm
! 2014-02-18 17:18:28.155 Using username "<unm>".
. 2014-02-18 17:18:28.171 Prompt (7, SSH password, , &Password: )
. 2014-02-18 17:18:28.171 Using stored password.
. 2014-02-18 17:18:28.171 Sent password
. 2014-02-18 17:18:28.217 Access granted
. 2014-02-18 17:18:28.217 Opening session as main channel
. 2014-02-18 17:18:28.233 Opened main channel
. 2014-02-18 17:18:28.295 Started a shell/command
. 2014-02-18 17:18:28.295 --------------------------------------------------------------------------
. 2014-02-18 17:18:28.295 Using SFTP protocol.
. 2014-02-18 17:18:28.311 Doing startup conversation with host.
> 2014-02-18 17:18:28.311 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2014-02-18 17:18:28.327 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2014-02-18 17:18:28.327 SFTP version 3 negotiated.
. 2014-02-18 17:18:28.327 We believe the server has signed timestamps bug
. 2014-02-18 17:18:28.327 We will use UTF-8 strings when appropriate
. 2014-02-18 17:18:28.327 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2014-02-18 17:18:28.327 Getting current directory name.
. 2014-02-18 17:18:28.327 Getting real path for '.'
> 2014-02-18 17:18:28.327 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2014-02-18 17:18:28.342 Type: SSH_FXP_NAME, Size: 71, Number: 16
. 2014-02-18 17:18:28.342 Real path is '/remote/dir/'
. 2014-02-18 17:18:28.342 Startup conversation with host finished.
< 2014-02-18 17:18:28.342 Script: Active session: [1] <unm>@<ftp-address>
> 2014-02-18 17:18:28.342 Script: put C:\LocalDir\*.xml /remote/dir/
. 2014-02-18 17:18:28.342 Copying 1 files/directories to remote directory "/remote/dir/"
. 2014-02-18 17:18:28.342   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask:
. 2014-02-18 17:18:28.342   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM:
. 2014-02-18 17:18:28.342   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2014-02-18 17:18:28.342 File: 'C:\LocalDir\FC00451_0001_0001.xml' [2014-02-18T01:45:56.463Z] [6199]
. 2014-02-18 17:18:28.342 Copying "C:\LocalDir\FC00451_0001_0001.xml" to remote directory started.
. 2014-02-18 17:18:28.342 Binary transfer mode selected.
. 2014-02-18 17:18:28.342 Opening remote file.
> 2014-02-18 17:18:28.342 Type: SSH_FXP_OPEN, Size: 69, Number: 259
< 2014-02-18 17:18:28.358 Type: SSH_FXP_HANDLE, Size: 13, Number: 259
> 2014-02-18 17:18:28.358 Type: SSH_FXP_WRITE, Size: 4121, Number: 774
. 2014-02-18 17:18:28.358 1 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2014-02-18 17:18:28.358 Type: SSH_FXP_CLOSE, Size: 13, Number: 1284
> 2014-02-18 17:18:28.358 Type: SSH_FXP_SETSTAT, Size: 65, Number: 521
< 2014-02-18 17:18:28.373 Type: SSH_FXP_STATUS, Size: 24, Number: 774
< 2014-02-18 17:18:28.607 Type: SSH_FXP_STATUS, Size: 24, Number: 1030
< 2014-02-18 17:18:28.607 Type: SSH_FXP_STATUS, Size: 24, Number: 1284
< 2014-02-18 17:18:28.607 Status code: 0
. 2014-02-18 17:18:28.607 Preserving timestamp [2014-02-18T01:45:56.000Z]
< 2014-02-18 17:18:28.607 Type: SSH_FXP_STATUS, Size: 24, Number: 521
< 2014-02-18 17:18:28.607 Status code: 0
> 2014-02-18 17:18:28.607 Script: exit
. 2014-02-18 17:18:28.607 Script: Exit code: 0
. 2014-02-18 17:18:28.607 Closing connection.
. 2014-02-18 17:18:28.607 Sending special code: 12
. 2014-02-18 17:18:28.607 Sent EOF message

Again, this is the batch script log (run manually). When I run the script from Task Scheduler, it does not generate a log at all. Very frustrating.

Any idea what I might be doing wrong?
Plasmastorm

Hi, I have the same issue in 5.2.7 (build 3780), anything scripted for SBS2011 (same as SBS2008 R2) scheduled task exits with error code of 1 when set to 'Run whether user is logged on or not'.

The bug does not seem to match the topic here?
martin

Re: Run whether user is logged on or not

Thanks for your report.
I have sent you an email with a debug version of WinSCP to address you have used to register on this forum.
usa

Run whether user is logged on or not

Under Windows Server 2008 R2, I have a .bat script which uses WinSCP and connects to a simple FTP server.

The script runs successfully:

  1. from the command line under the local administrator account

  2. from the Task Scheduler under the local administrator account with the following settings:
    (*) Run only when user is logged on

  3. from the Task Scheduler under the local administrator account with the following settings:
    (*) Run whether user is logged on or not
    Configure for: Windows Server(tm) 2003, Windows(R) XP, or Windows(R) 2000
    But it FAILS:

  4. from the Task Scheduler under the local administrator account with the following settings:
    (*) Run whether user is logged on or not
    Configure for: Windows Vista(tm), Windows Server(tm) 2008 / Windows(R) 7, Windows Server(tm) 2008 R2

Yes, I have read the FAQ.

The log file says:
. 2013-09-11 22:42:58.353 --------------------------------------------------------------------------
. 2013-09-11 22:42:58.353 WinSCP Version 5.1.7 (Build 3446) (OS 6.1.7601 Service Pack 1)
. 2013-09-11 22:42:58.353 Configuration: *****\WinSCP.ini
. 2013-09-11 22:42:58.353 Local account: *****\Administrator
. 2013-09-11 22:42:58.353 Working directory: *****
. 2013-09-11 22:42:58.353 Process ID: 35612
. 2013-09-11 22:42:58.353 Command-line: "*****\WinSCP.exe" /console=517 /consoleinstance=_29000_670 "/script=*****\winscp.txt" "/log=*****\log.log"
. 2013-09-11 22:42:58.353 Time zone: *****
. 2013-09-11 22:42:58.353 Login time: *****
. 2013-09-11 22:42:58.353 --------------------------------------------------------------------------
. 2013-09-11 22:42:58.353 Session name: *****@ftp.*****.com (Ad-Hoc session)
. 2013-09-11 22:42:58.353 Host name: ftp.*****.com (Port: 21)
. 2013-09-11 22:42:58.353 User name: ***** (Password: Yes, Key file: No)
. 2013-09-11 22:42:58.353 Tunnel: No
. 2013-09-11 22:42:58.353 Transfer Protocol: FTP
. 2013-09-11 22:42:58.353 Ping type: C, Ping interval: 30 sec; Timeout: 15 sec
. 2013-09-11 22:42:58.353 Proxy: none
. 2013-09-11 22:42:58.353 FTP: FTPS: None; Passive: Yes [Force IP: A]; List all: A
. 2013-09-11 22:42:58.353 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2013-09-11 22:42:58.353 Cache directory changes: Yes, Permanent: Yes
. 2013-09-11 22:42:58.353 DST mode: 1; Timezone offset: 0h 0m
. 2013-09-11 22:42:58.353 --------------------------------------------------------------------------
. 2013-09-11 22:42:58.353 Connection failed.


Actually, the configuration #3 is enough for me, but it shows a console window if the administrator is logged on.

Please help me make the configuration #4 work.