# Executing DOS Commands/batch files from Test Step?

**URL:** <https://forum.opentap.io/t/executing-dos-commands-batch-files-from-test-step/1319>\
**Category:** Technical\
**Created:** [December 11, 2023, 4:10pm UTC](https://forum.opentap.io/t/executing-dos-commands-batch-files-from-test-step/1319 "2023-12-11T16:10:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ipa\_test](https://avatars.discourse-cdn.com/v4/letter/i/3e96dc/32.png) [@ipa\_test](https://forum.opentap.io/u/ipa_test)\
**Post date:** [December 11, 2023, 4:10pm UTC](https://forum.opentap.io/t/executing-dos-commands-batch-files-from-test-step/1319/1 "2023-12-11T16:10:58Z")

</div>

I am trying to figure out how to execute DOS commands, or potentially launch a batch file from a test step. I am submitting JSON files to another application from TAP, but I need to launch the other application first before I can run any of the test steps. I am sure you can do this, but I have not been able to find any reference to this in the documentation, or on Google.

There will be log files updated from my application, and I think I can figure out how to check those files for status of launching the application, but will need to do this as well.

---

<div class="post-metadata">

**Author:** ![craig.petku](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@craig.petku](https://forum.opentap.io/u/craig.petku)\
**Post date:** [December 11, 2023, 9:39pm UTC](https://forum.opentap.io/t/executing-dos-commands-batch-files-from-test-step/1319/2 "2023-12-11T21:39:19Z")

</div>

Have you tried something like this? I tend to use it with xcopy and various drives. The issue I have had is the cmd window can’t open in minimized so it’s awkward when spawning a lot of tasks rapidly. One solution is to prepend the command with start and set the minimized option. The problem when doing this is loss of the returned (error level) value.

[Step\_CommandLine.cs](https://forum.opentap.io/uploads/short-url/qESyrRynLocbC8YvPfh1gprKonx.cs) (3.6 KB)

---

<div class="post-metadata">

**Author:** ![sebastian.pop.v](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@sebastian.pop.v](https://forum.opentap.io/u/sebastian.pop.v)\
**Post date:** [December 18, 2023, 5:02pm UTC](https://forum.opentap.io/t/executing-dos-commands-batch-files-from-test-step/1319/3 "2023-12-18T17:02:40Z")

</div>

Try using the “Run Program” step which comes by default with OpenTAP, to execute CMD commands with arguments. It also has regex for the output of the command.  
You can use the “If Verdict” step for conditions.

---

<div class="post-metadata">

**Author:** ![ipa\_test](https://avatars.discourse-cdn.com/v4/letter/i/3e96dc/32.png) [@ipa\_test](https://forum.opentap.io/u/ipa_test)\
**Post date:** [December 18, 2023, 5:20pm UTC](https://forum.opentap.io/t/executing-dos-commands-batch-files-from-test-step/1319/4 "2023-12-18T17:20:39Z")

</div>

This looks like it would give me a lot of control, I may try to adopt this.

---

<div class="post-metadata">

**Author:** ![ipa\_test](https://avatars.discourse-cdn.com/v4/letter/i/3e96dc/32.png) [@ipa\_test](https://forum.opentap.io/u/ipa_test)\
**Post date:** [December 18, 2023, 5:21pm UTC](https://forum.opentap.io/t/executing-dos-commands-batch-files-from-test-step/1319/5 "2023-12-18T17:21:07Z")

</div>

Any idea where I could get more details on this. Going through the TAP manual, not seeing anything obvious.
