# Get tasklist.exe output

**URL:** <https://forum.inductiveautomation.com/t/get-tasklist-exe-output/18614>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [June 25, 2018, 10:25pm UTC](https://forum.inductiveautomation.com/t/get-tasklist-exe-output/18614 "2018-06-25T22:25:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwj](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@kwj](https://forum.inductiveautomation.com/u/kwj)\
**Post date:** [June 25, 2018, 10:25pm UTC](https://forum.inductiveautomation.com/t/get-tasklist-exe-output/18614/1 "2018-06-25T22:25:12Z")

</div>

I can’t think of a way to get running tasks on the ignition gateway on windows. Can’t seem import psutil or get stdout from system.util.execute. Anybody got anything? I have a process that needs to be started if it is not running for some reason, and want to check first obviously.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [June 25, 2018, 10:32pm UTC](https://forum.inductiveautomation.com/t/get-tasklist-exe-output/18614/2 "2018-06-25T22:32:49Z")

</div>

Check out ProcessBuilder.

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [June 27, 2018, 3:15pm UTC](https://forum.inductiveautomation.com/t/get-tasklist-exe-output/18614/3 "2018-06-27T15:15:41Z")

</div>

Check this [https://www.blog.pythonlibrary.org/2010/10/03/how-to-find-and-list-all-running-processes-with-python/](https://www.blog.pythonlibrary.org/2010/10/03/how-to-find-and-list-all-running-processes-with-python/)  
At the end of the article, you’ll find “The Cross-Platform Solution!”.

Hope this will help you out

Cheers,

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [June 27, 2018, 7:49pm UTC](https://forum.inductiveautomation.com/t/get-tasklist-exe-output/18614/4 "2018-06-27T19:49:36Z")

</div>

That won’t work. psutil does not exist in Jython.

kwj, you will have to invoke a native task manager app and pull the results back using ProcessBuilder.

---

<div class="post-metadata">

**Author:** ![c.bertulli](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@c.bertulli](https://forum.inductiveautomation.com/u/c.bertulli)\
**Post date:** [June 28, 2018, 6:37am UTC](https://forum.inductiveautomation.com/t/get-tasklist-exe-output/18614/5 "2018-06-28T06:37:24Z")

</div>

This is a script I made for an old project.  
It checks if a specific process is running or not. ( in this case I put chrome.exe as an example )

[code]import subprocess

def processExists(processname):  
command = ‘TASKLIST’, ‘/FI’, ‘imagename eq %s’ % processname  
# shell=True hides the shell window, stdout to PIPE enables communicate() to get the tasklist command result  
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)  
# trimming it to the actual lines with information  
process\_out = process.communicate()[0].strip().split(’\r\n’)  
# if TASKLIST returns single line without processname: it’s not running  
if len(process\_out) \> 1 and processname in process\_out[-1]:  
print(‘process “%s” is running!’ % processname)  
return True  
else:  
print(‘process “%s” is NOT running!’ % processname)  
return False

processExists(‘chrome.exe’) [/code]

---

<div class="post-metadata">

**Author:** ![kwj](https://avatars.discourse-cdn.com/v4/letter/k/838e76/32.png) [@kwj](https://forum.inductiveautomation.com/u/kwj)\
**Post date:** [July 5, 2018, 4:34pm UTC](https://forum.inductiveautomation.com/t/get-tasklist-exe-output/18614/6 "2018-07-05T16:34:27Z")

</div>

This is perfect. Thank you very much.
