If you invoke a batch file with PSEXEC you will likely experience an issue where the batch file completes...but PSEXEC seems to hang. This can happen if you don't have an Exit command embedded within the batch file. This happens because the batch file completes but the CMD.exe is still running. Using the EXIT command will close the batch file and close the cmd.exe.
One thing to note, if you just use the exit command then PSEXEC will produce an error code of 1, regardless of the ERRORLEVEL you may have set in the batch file.
To get around this, use the EXIT with the available options.
Example: exit /b 0
Explanation: exits the batch file, closes the cmd.exe, and sets the return code to zero.
Example: exit /b -2
Explanation: exits the batch file, closes the cmd.exe, and sets the return code to zero
Hope this helps.
Share This To :
0 comments:
Post a Comment