James Ray Anderson

James Ray Anderson
James Ray Anderson
0 comments

PSEXEC Hangs After Invoking a Batch File

10:00 AM
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.

0 comments:

 
Toggle Footer
Top