Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:51:37+00:00 2026-06-15T21:51:37+00:00

If I run a successful PSEXEC command, it says this… cmd exited on workstation.domain

  • 0

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.
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:51:37+00:00Added an answer on June 15, 2026 at 9:51 pm

    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?

    psexec \\workstation.domain -u username -p password cmd /c "assoc.pdf= "
    IF '%ERRORLEVEL%'=='0' (
      echo Success!
    ) else (
      REM display psexec error here.
    )
    

    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.

    verify >nul
    

    In this case I would do the following:

    verify >nul
    psexec \\workstation.domain -u username -p password cmd /c "assoc.pdf= "
        IF '%ERRORLEVEL%'=='0' (
          echo Success!
        ) else (
          echo.Error is %ERRORLEVEL%; please see http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx for more details.
        )
    

    I added a weburl for checking on the error received.

    Alternatively you could open the URL to the corresponding page automatically:

    @ECHO OFF
        verify >nul
        set ERRCODE=0
        psexec \\workstation.domain -u username -p password cmd /c "assoc.pdf= "
            IF '%ERRORLEVEL%'=='0' (
              echo Success!
            ) else (
              set ERRCODE=%ERRORLEVEL%
            )
    IF %ERRCODE% LEQ 499 set MSERROR=681382
    IF %ERRCODE% GTR 500 set MSERROR=681388
    IF %ERRCODE% GTR 1000 set MSERROR=681383
    IF %ERRCODE% GTR 1300 set MSERROR=681385
    IF %ERRCODE% GTR 1700 set MSERROR=681386
    IF %ERRCODE% GTR 4000 set MSERROR=681387
    IF %ERRCODE% GTR 6000 set MSERROR=681389
    IF %ERRCODE% GTR 8200 set MSERROR=681390
    IF %ERRCODE% GTR 9000 set MSERROR=681391
    IF %ERRCODE% GTR 12000 set MSERROR=681384
    
    IF ERRCODE NEQ 0 start http://msdn.microsoft.com/en-us/library/ms%MSERROR%(v=vs.85).aspx
    IF ERRCODE NEQ 0 echo.This failed with ERROR: %ERRCODE%
    pause
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any easy way to automatically run my unit tests after a successful
I am following this tutorial and I've run the command ruby script\server and successfully
I have this error while trying to run my program. I am still wondering
I run this query in mongo shell, and successful get result db.tablebusiness.find({ LongitudeLatitude :
I would like to run a small PHP Code after the successful Registration. Means
How i will run this piece of java code???? import java.io.Console; import java.util.Arrays; /**
is it possible to run f# code on server if it's not installed there
I was able to successfully run an RF model using some R code I
I'm attempting to run a series of commands programmatically, read the error codes, and
I'm trying to run code within JBoss Container under a different authentication by programatically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.