When i am running below code from vbscript always i am getting error status as 0 in a log file irrespective of error code but when i run the same code from command prompt i am getting error code 127. below is the vbscript code
set objShell = WScript.CreateObject ("WScript.Shell")
str = "plink.exe -ssh user@host -pw gbG8qs4D /remote_linux_server/listoffiles.sh > C:\count_data_csv.txt"
error = "error %ErrorLevel%" >> C:\count_data_csv.txt"
objShell.run "cmd /k " & str & "&" & error
Set objShell = Nothing
Please let me know why there is a difference in error code
But after running above vbscript command if i check error code in command prompt i am getting error code 127 which is correct but my vbscript doesn't able to redirect same error code in count_data_csv.txt :(
error
for a variable, replaced byXerror
cmd /V:ON ...
enables delayed expansion which is put to use by!ErrorLevel!
instead of%errorlevel%
echo