If I run a successful PSEXEC command, it says this…
“cmd exited on workstation.domain with error code 0.”
Is there any way I can prevent this and do something like
psexec \\workstation.domain -u username -p password cmd /c "assoc.pdf= "
if %errorlevel%==0 (
echo Success!
) else (
REM display psexec error here.
)
Since my edit’s were rejected…
Is the original code posted part of a larger script? If so then do you set your errcode to match the ERRORLEVEL environment variable?
Whenever attempting to detemine IF / THEN in batch and you use == you need to surrond the variable and the valuecheck in single ” ‘ ” marks. The above code corrects that issue for you as well as replaces errcode with ERRORLEVEL, which is the default environment variable for Windows.
Also, in practice I always use the following before any ERRORLEVEL check to drop the initial value to properly catch the error.
In this case I would do the following:
I added a weburl for checking on the error received.
Alternatively you could open the URL to the corresponding page automatically: