# Problem running grunt in .bat using Run DOS Command

**URL:** https://www.finalbuilder.com/forums/t/problem-running-grunt-in-bat-using-run-dos-command/3454
**Category:** Bugs
**Created:** [October 10, 2012, 8:53am UTC](https://www.finalbuilder.com/forums/t/problem-running-grunt-in-bat-using-run-dos-command/3454 "2012-10-10T08:53:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 10, 2012, 8:53am UTC](https://www.finalbuilder.com/forums/t/problem-running-grunt-in-bat-using-run-dos-command/3454/1 "2012-10-10T08:53:30Z")

</div>

Prerequisites:   
 Python 2.7.3   
 Java   
 nodejs   
 [grunt]([https://github.com/cowboy/grunt](https://github.com/cowboy/grunt)) `npm install -g grunt`   
  
 Here is the weirdness grunt works fine if I run it on the command line or if I put it into a batch file and run that manually. But if I put either into Action: “Run DOS Command / Batch File”, or the Action:“Execute Program”. I get the below error message. Now what’s curious about the error is that the tmp%GUID%.stdout does not exist, and it’s clear that the file is a Finalbuilder tmp file.   
  
  
 Error Message:   
  
 C:\Projects\trunk\MMWebHTML\mj\viewer\>grunt.cmd   
 [4mRunning “gloablize” task[24m   
 Error: ENOENT, no such file or directory ‘C:\Users\BUILD~1.MIN\AppData\Local\Temp\2\tmp1349893925353005205364874564111.stdout’   
 at Object.fs.openSync (fs.js:338:18)   
 at Object.fs.readFileSync (fs.js:182:15)   
 at getOutput (C:\Projects\trunk\MMWebHTML\mj\viewer\node\_modules\grunt-steal\node\_modules\exec-sync\bin\index.js:39:17)   
 at module.exports (C:\Projects\trunk\MMWebHTML\mj\viewer\node\_modules\grunt-steal\node\_modules\exec-sync\bin\index.js:59:14)   
 at Object.module.exports (C:\Projects\trunk\MMWebHTML\mj\viewer\node\_modules\grunt-steal\tasks\steal.js:31:20)   
 at Object.task.registerTask.thisTask.fn (C:\Users\build.MINDJETQA\AppData\Roaming\npm\node\_modules\grunt\lib\grunt\task.js:58:16)   
 at Task. (C:\Users\build.MINDJETQA\AppData\Roaming\npm\node\_modules\grunt\lib\util\task.js:341:36)   
 at Task. (C:\Users\build.MINDJETQA\AppData\Roaming\npm\node\_modules\grunt\lib\util\task.js:317:9)   
 at Task. (C:\Users\build.MINDJETQA\AppData\Roaming\npm\node\_modules\grunt\lib\util\task.js:344:11)   
 at Task. (C:\Users\build.MINDJETQA\AppData\Roaming\npm\node\_modules\grunt\lib\util\task.js:317:9)   
 Program returned code : 1

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 17, 2012, 1:08am UTC](https://www.finalbuilder.com/forums/t/problem-running-grunt-in-bat-using-run-dos-command/3454/2 "2012-10-17T01:08:05Z")

</div>

So I also tried this on Jenkins with similar results. After talking to support I’m left with a problem I don’t know how to address. Apparently grunt can not be redirected through cmd.   
  
 So Final Builder (and Jenkins) creates a wrapper bat file and then pipes that into cmd. For whatever reason this action is causing the process to blow up. Which leads up the creek for possible solutions.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [October 17, 2012, 2:33am UTC](https://www.finalbuilder.com/forums/t/problem-running-grunt-in-bat-using-run-dos-command/3454/3 "2012-10-17T02:33:08Z")

</div>

If you use the Execute Program action, it does not create a wrapper bat. A .cmd file is a batch file, and should be executed using the Run Dos Command action, which invokes the command interpreter (cmd.exe) and passes it the batch file. Did you try that?

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 23, 2012, 11:34am UTC](https://www.finalbuilder.com/forums/t/problem-running-grunt-in-bat-using-run-dos-command/3454/4 "2012-10-23T11:34:54Z")

</div>

I had tried using calling node.exe with the grunt as the parameter. But calling cmd directly is a good suggestion. Of course I get very similar error output.   
  
 [4mRunning “gloablize” task[24m   
 Error: ENOENT, no such file or directory ‘C:\Users\BUILD~1.MIN\AppData\Local\Temp\2\tmp1351027883012008680653204210103.stdout’   
 at Object.fs.openSync (fs.js:338:18)   
 at Object.fs.readFileSync (fs.js:182:15)   
 at getOutput (C:\Projects\trunk\MMWebHTML\mj\viewer\node\_modules\grunt-steal\node\_modules\exec-sync\bin\index.js:39:17)   
 at module.exports (C:\Projects\trunk\MMWebHTML\mj\viewer\node\_modules\grunt-steal\node\_modules\exec-sync\bin\index.js:59:14)   
 at Object.module.exports (C:\Projects\trunk\MMWebHTML\mj\viewer\node\_modules\grunt-steal\tasks\steal.js:31:20)   
 at Object.task.registerTask.thisTask.fn (C:\Users\build.MINDJETQA\AppData\Roaming\npm\node\_modules\grunt\lib\grunt\task.js:58:16)   
 at Task. (C:\Users\build.DOMAIN\AppData\Roaming\npm\node\_modules\grunt\lib\util\task.js:341:36)   
 at Task. (C:\Users\build.DOMAIN\AppData\Roaming\npm\node\_modules\grunt\lib\util\task.js:317:9)   
 at Task. (C:\Users\build.DOMAIN\AppData\Roaming\npm\node\_modules\grunt\lib\util\task.js:344:11)   
 at Task. (C:\Users\build.DOMAIN\AppData\Roaming\npm\node\_modules\grunt\lib\util\task.js:317:9)   
 Program returned code : 1

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [October 31, 2012, 12:30pm UTC](https://www.finalbuilder.com/forums/t/problem-running-grunt-in-bat-using-run-dos-command/3454/5 "2012-10-31T12:30:25Z")

</div>

Ok I got calling cmd to work but I’m puzzled on how to convert this into a final builder action.   
  
 **cmd /c “cd C:\working\directory\without\spaces && grunt.bat”** Gets it to create the expected out put.   
  
 However when I set this up as a Final builder action it fails spectacularly.   
 **Execute Program**   
 **Program File:** cmd.exe   
 **Parameters:** /C grunt.bat   
 **Start In:** C:\working\directory\without\space
