Author: ianthegreater
Subject: Getting PSExec error codes from remote batch file
Posted: 22 November 2013 at 9:10pm
Hi all,
Edited by ianthegreater - 1 hour 49 minutes ago at 9:11pm
Subject: Getting PSExec error codes from remote batch file
Posted: 22 November 2013 at 9:10pm
Hi all,
I'm using PSExec within a batch file call to copy another batch file to a remote machine. I was hoping to get the error codes from the remote batch file passed back through PSExec, then finally to the original batch file to make sure that everything executed properly. However, I'm unable to get the error codes from the remote batch file to PSExec. Here's how the code is set up:
Original Batch File:
@echo off
start /min /wait psexec \\%1 -e -u <Username> -p <Password> -c -f "<File to Copy>"
EXIT /B %ERRORLEVEL%
The PSExec call is executing properly but not passing any information about the error codes.
Remote Batch File:
net use H: /delete
net use H: "<Path to Map to>" /user:<username and credentials> /persistent:no
H:
<Execute Program> %1
EXIT /B %ERRORLEVEL%
I'm not sure if I'm doing something incorrectly - I can get PSExec to execute as desired, but it always returns with error code 0.
Appreciate the help,
Ian
Edited by ianthegreater - 1 hour 49 minutes ago at 9:11pm