Thanks for the response.
I am using %comspec& /c just so I can run multiple commands. However, I have discarded the errorlevel statement now and I am just using one statement, which is the winscp /command statement.
I have enclosed the piece of vbscript code that runs this command and the output as well. Please check it at your earliest convenience and let me know what could be causing the exit code to come out as 0 always.
*********************************
VBScript Code:
*********************************
FTPCommand = "winscp /command "echo @@@@@@ Setting command options: " "option confirm off" "option batch abort" "option exclude */" "echo @@@@@@ Connecting to FTP server: " "open USERNAME:
[email protected]" "echo @@@@@@ Setting local directory: " "lcd D:\FTPJobs_ScriptLibrary\TEST\Inbox\" "echo @@@@@@ Setting remote directory: " "cd Example/Test/" "echo @@@@@@ Setting file transfer mode: " "binary" "echo @@@@@@ Listing contents of remote directory: " "ls" "echo @@@@@@ Transferring file(s): " "get *.pgp -nopermissions -nopreservetime" "echo @@@@@@ Disconnecting from FTP server: " "bye" /log="WinSCP_SessionLog.txt""
Set objShell = WScript.CreateObject("WScript.Shell")
Set objShellExecute = objShell.Exec(FTPCommand)
FTPSessionExitCode = objShellExecute.ExitCode
FTPSessionResult = objShellExecute.StdOut.ReadAll()
If FTPSessionExitCode = 0 Then
FTPSessionResult = FTPSessionResult & "Batch Script executed. FTP Session completed without error(s). Exit Code: " & FTPSessionExitCode
Else
FTPSessionResult = FTPSessionResult & "Error(s) occurred with batch script execution or within the FTP Session. Exit Code: " & FTPSessionExitCode
GlobalErrorLevel = 1
End If
Set objShellExecute = Nothing
Set objShell = Nothing
*********************************
Script Output
*********************************
***********************************************
10/4/2013 9:40:01 AM | BEGIN: Script Log
***********************************************
10/4/2013 9:40:01 AM | Downloading file(s) from FTP Server to Temp Directory:
|@@@@@@ Setting command options:
|confirm off
|batch abort
|include |*/
|@@@@@@ Connecting to FTP server:
|Searching for host...
|Connecting to host...
|Authenticating...
|Using username "USERNAME".
|Authenticating with pre-entered password.
|Authenticated.
|Starting the session...
|Reading remote directory...
|Session started.
|Active session: [1]
[email protected]
|@@@@@@ Setting local directory:
|D:\FTPJobs_ScriptLibrary\TEST\Inbox
|@@@@@@ Setting remote directory:
|Error changing directory to 'Example/Test/'.
|Cannot get real path for '/Example/Test/'.
|No such file or directory.
|Error code: 2
|Error message from server (en): File not found
|Request code: 16
|/
|
Batch Script executed. FTP Session completed without error(s). Exit Code: 0
Step: DownloadFiles: Completed without error(s).
***********************************************
10/4/2013 9:40:01 AM | Checking Temp Directory:
No. of file(s) in the Temp Directory: 0
No input files for this file transaction.
***********************************************
10/4/2013 9:40:01 AM | END: Script Log