# Execute dos command in node-red

**URL:** <https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809>\
**Category:** General\
**Created:** [29 March 2020 02:22 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809 "2020-03-29T02:22:17Z")\
**Posts on this page:** 11\
**Page:** 3

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 March 2020 08:21 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/42 "2020-03-30T08:21:57Z")

</div>

Well at least that gets rid of the possible confusion with the slashes. Is the problem possibly that you are not running it from the `c:/impl` directory? I you run it from the command line but not from `c:/impl` and with the full path to the command does it work. Possibly it expects the missing file to be in the current directory.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [30 March 2020 08:26 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/43 "2020-03-30T08:26:17Z")

</div>

The command appears to run successfully, except that it cannot find the setting file.  
@Munier are you sure there is no environment set for this software ? I think it is the `set` command, to see all the configured paths and environment variables on windows.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 March 2020 08:27 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/44 "2020-03-30T08:27:01Z")

</div>

I'll throw in a _curve ball_ here.

Though I dismissed them before, how about a `.bat` file?

Put this file somewhere in a SIMPLE path that is easy for the O/S to find.

Of course the `.bat` file will need to also have all the paths in it, but that is handled by the O/S and so **shouldn't be** a problem as it seems there is now.

Just a thought.

---

<div class="post-metadata">

**Author:** ![Munier](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@Munier](https://discourse.nodered.org/u/Munier)\
**Post date:** [30 March 2020 08:34 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/45 "2020-03-30T08:34:48Z")

</div>

> [@Colin](#):
>
> Is the problem possibly that you are not running it from the `c:/impl` directory?

What is shown in the workspace of node-red is successful execution of IMPL command i.e., `c:/IMPL` the issues is that the exec can't read the model files configured in IMPL. MassBalancing is where the code configured for the model is. it has `.iml` extension which executable in window cmd for IMPL directory. I will try to add the extension and see.

---

<div class="post-metadata">

**Author:** ![Munier](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@Munier](https://discourse.nodered.org/u/Munier)\
**Post date:** [30 March 2020 08:43 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/46 "2020-03-30T08:43:06Z")

</div>

> [@bakman2](#):
>
> are you sure there is no environment set for this software ?

When you said environment set are you referring to this.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/0/00033f9e12ebf8071c0c21a7b2be560e8bc37819.png)

This part is where the exec node fails.

---

<div class="post-metadata">

**Author:** ![Munier](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@Munier](https://discourse.nodered.org/u/Munier)\
**Post date:** [30 March 2020 08:46 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/47 "2020-03-30T08:46:37Z")

</div>

> [@Trying\_to\_learn](#):
>
> Though I dismissed them before, how about a `.bat` file?

I have tried your approach and it is the same output

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 March 2020 08:48 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/48 "2020-03-30T08:48:10Z")

</div>

Rather than putting that _command_ into the `exec` node:

Put the command in a very easily accessible `.bat` file which will do the command, and do the `.bat` file in the `exec` node.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [30 March 2020 08:54 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/49 "2020-03-30T08:54:34Z")

</div>

This is the same as the exec node.

@munier, open a cmd window and type `set`, what is the output - would be useful if you include the commands you are executing (as we only see output).

---

<div class="post-metadata">

**Author:** ![Munier](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@Munier](https://discourse.nodered.org/u/Munier)\
**Post date:** [30 March 2020 09:13 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/50 "2020-03-30T09:13:33Z")

</div>

> [@bakman2](#):
>
> would be useful if you include the commands you are executing (as we only see output).

The command I execute for IMPL model is from IMPL executable (console).

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 March 2020 09:21 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/51 "2020-03-30T09:21:13Z")

</div>

(I think all that is requested is you type the **commands** you are entering. Not a screen shot.)

And of course it raises the question why there are fifty posts to determine there is more than one command being used.

---

<div class="post-metadata">

**Author:** ![SrGeneroso](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/srgeneroso/32/69531_2.png) [@SrGeneroso](https://discourse.nodered.org/u/SrGeneroso)\
**Post date:** [22 October 2022 17:25 UTC](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809/52 "2022-10-22T17:25:16Z")

</div>

This thread is gold.

[Previous page](https://discourse.nodered.org/t/execute-dos-command-in-node-red/23809.md?page=2)
