# System.util.execute question

**URL:** <https://forum.inductiveautomation.com/t/system-util-execute-question/18227>\
**Category:** Ignition\
**Created:** [May 30, 2018, 3:21pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227 "2018-05-30T15:21:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nruimveld](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@nruimveld](https://forum.inductiveautomation.com/u/nruimveld)\
**Post date:** [May 30, 2018, 3:21pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/1 "2018-05-30T15:21:37Z")

</div>

When I run system.util.execute([“C:\windows\system32\cmd.exe”,"/C",“start”,“C:\Users\Nick Ruimveld\Documents\Hello.bat”]), this is what is shown:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/95099a2be5c29a959068fd5f2b6cb10703ab51cf.png)

This is what’s inside the batch file:

echo off  
title Hello World!  
:: See the title at the top.  
echo Test file executed.  
echo I am too lazy to write commands again and again.  
pause

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [May 30, 2018, 5:18pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/2 "2018-05-30T17:18:06Z")

</div>

Backslashes need to be escaped with, of all things, a backslash

```auto
system.util.execute(["C:\\windows\\system32\\cmd.exe","/C","start","C:\\Users\\Nick Ruimveld\\Documents\\Hello.bat"])

```

Python is also pretty forgiving on paths using forward slashes:

```auto
system.util.execute(["C:/windows/system32/cmd.exe","/C","start","C:/Users/Nick Ruimveld/Documents/Hello.bat"])

```

---

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [June 11, 2018, 4:59pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/3 "2018-06-11T16:59:18Z")

</div>

Just curious, how would you deal with files that have space in them?  
I know you can put double quotations around the file name if you’re actually in cmd.exe in windows:  
`C:\users\userName\Desktop\"name name.jpg"`  
and it works just fine but how would you do that if you are running system.util.execute() in Ignition?  
I tried to squeez the double quotation in there but didn’t like it, kept openning  
`C:\users\userName\Downloads`

asking for a friend 😁 🤓

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 11, 2018, 5:03pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/4 "2018-06-11T17:03:55Z")

</div>

You should be able to swap the quotes around, eg use single quotes around the Python character sequence, which will then pass unmodified (including double quotes) to the execute function:  
`system.util.execute(['cmd.exe', '"C:\Users\username\Desktop\some long file name.jpg"'])`

---

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [June 11, 2018, 5:25pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/5 "2018-06-11T17:25:06Z")

</div>

Thanks for the quick reply @paul-griffith  
I tried your way and it wouldn’t even open the cmd. It doesn’t like the ‘cmd.exe’ by itself, I had to use: `'C:/windows/system32/cmd.exe','/C','start'`  
for it to even do anything and even after that still opens:  
`C:\users\userName\Downloads` (when done in designer)  
and  
`C:\windows\system32` (when done in client)  
Even if I only point the path to Desktop but the moment i take away either the double quotes or single quotes it opens the Desktop just fine.  
Any other suggestions?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [June 11, 2018, 6:23pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/6 "2018-06-11T18:23:32Z")

</div>

> [@paul-griffith](#):
>
> system.util.execute(['cmd.exe', '"C:\Users\username\Desktop\some long file name.jpg"'])

Close 🙂

Here's one that worked for me.

`system.util.execute(['cmd.exe', '/C', 'C:/Users/username/Desktop/some long file name.jpg'])`

No double quotes should be needed.

EDIT: If you are trying to open a file, then 'start' shouldn't be needed, either.

---

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [June 11, 2018, 7:39pm UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/7 "2018-06-11T19:39:38Z")

</div>

Thanks @JordanCClark 👍

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [January 19, 2024, 8:14am UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/8 "2024-01-19T08:14:55Z")

</div>

question, maybe I'm doing something wrong but I only have this in my actionperformed code and it still won't open cmd.exe:

```auto
system.util.execute(['cmd.exe'])

```

when I do notepad instead of cmd it will open notepad but cmd doesn't work for some reason.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 19, 2024, 10:56am UTC](https://forum.inductiveautomation.com/t/system-util-execute-question/18227/9 "2024-01-19T10:56:06Z")

</div>

cmd closes after execution. run `start` from the cmd to open a window.

```auto
system.util.execute(['C:/windows/system32/cmd.exe','/C','start'])

```

To start in your user profile:

```auto
system.util.execute(['C:/windows/system32/cmd.exe','/C', 'start /d %USERPROFILE%'])

```
