Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

mj9100

yes, configure for: was incorrect changing it fix my 'last run result' code

thank you!!!
DZY

Thank you!

@sig: You made it, was totally blind for the OS Version.
sig

I was having problems getting Task Sched to run my batch file, too. I'm using Windows Server 2008 R2.

I had to do two things:
1. Under Actions I had to add the folder to the "Start in" input. This allowed my batch file to run, but I was still getting the 0x1 Result code.
2. Under General I had to change the Configure for: to the correct operating system (not sure why it defaults to the incorrect one). This got rid of the 0x1 code.
martin

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

@SRK: Yes, if your script uses local paths relative to the script path or WinSCP executable path, specify the respective path in Scheduler's Start in field.
I have documented this in https://winscp.net/eng/docs/guide_schedule
riceric

Windows Server Task Scheduler gives 0x1 as Last Run Result

I am having a similar problem, and the FAQ below did not seem to help.
https://winscp.net/eng/docs/faq_scheduler

I am running Windows Server 2008 R2; The latest version of 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 for several months until recently...not sure what changed...possible an update to WinSCP). 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 (run manually):
. 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?