# Windows batch w/ error ends unexpectedly w/ status 'Success'

**URL:** <https://community.jenkins.io/t/windows-batch-w-error-ends-unexpectedly-w-status-success/4884>\
**Category:** Ask a question\
**Created:** [December 9, 2022, 12:19pm UTC](https://community.jenkins.io/t/windows-batch-w-error-ends-unexpectedly-w-status-success/4884 "2022-12-09T12:19:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KC42](https://avatars.discourse-cdn.com/v4/letter/k/71c47a/32.png) [@KC42](https://community.jenkins.io/u/KC42)\
**Post date:** [December 9, 2022, 12:19pm UTC](https://community.jenkins.io/t/windows-batch-w-error-ends-unexpectedly-w-status-success/4884/1 "2022-12-09T12:19:40Z")

</div>

Hello

I created a simple job in Jenkins executing a short sequence of basic batch commands in Windows intentionally with an error to induce a failed build. The log registered the error (as expected) but finished with status: ‘Success’ (not as expected!).

**Shouldn’t this job end with status: ‘Failed’?**

A similar job with an intentional error ends on Debian as ‘Failed’ in Jenkins (as expected). That’s why I expected the job on Windows to fail alike.

Console output of executed job:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/9/950d29681ba94da8c904b289be7837146bb35400.png)

---

<div class="post-metadata">

**Author:** ![JanneK](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/jannek/32/2907_2.png) [@JanneK](https://community.jenkins.io/u/JanneK)\
**Post date:** [December 9, 2022, 12:24pm UTC](https://community.jenkins.io/t/windows-batch-w-error-ends-unexpectedly-w-status-success/4884/2 "2022-12-09T12:24:08Z")

</div>

You didn’t provide the “simple job” in which the error is.  
It’s most likely that you are running multiple commands and ignoring the failures, and then return successfully from the cmd at the end of your script - which obviously counts as a success.

---

<div class="post-metadata">

**Author:** ![KC42](https://avatars.discourse-cdn.com/v4/letter/k/71c47a/32.png) [@KC42](https://community.jenkins.io/u/KC42)\
**Post date:** [December 9, 2022, 12:33pm UTC](https://community.jenkins.io/t/windows-batch-w-error-ends-unexpectedly-w-status-success/4884/3 "2022-12-09T12:33:41Z")

</div>

Thank you for your reply @JanneK.

The script consists only of **echo** and **sleep commands**.  
The error is invoked in the line with ‘xxxx’ which is obviously not a valid command.

Here’s the script:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/4/431593dc1a1238054109e1c461205ce807d068ec.png)

---

<div class="post-metadata">

**Author:** ![KC42](https://avatars.discourse-cdn.com/v4/letter/k/71c47a/32.png) [@KC42](https://community.jenkins.io/u/KC42)\
**Post date:** [December 9, 2022, 12:56pm UTC](https://community.jenkins.io/t/windows-batch-w-error-ends-unexpectedly-w-status-success/4884/4 "2022-12-09T12:56:47Z")

</div>

You are right @JanneK, the script doesn’t abort after encountering the unrecognized ‘xxxx’ line but is going on until the end of the script and returns with status ‘Success’. On Linux an unrecognized command aborts the script. That’s the difference.

Thanks!
