How to check if a program is running with Ruby?
-
I am pretty sure this can be done. I have done some research but have not found what I am looking for yet.
I just need to know if a given program is running.
Something like this:
if ("indigo.exe").is_running? do something end
Maybe it has to be done with a system call...but which call?
-
here is one quick way
require "win32ole" procs = WIN32OLE.connect("winmgmts;\\\\.") all_proc = [] procs.InstancesOf("win32_process").each do |proc| all_proc.push proc.name.to_s.downcase end p all_proc.include?("indigo.exe")
-
Thanks, but I get this error message when SketchUp loads:
Error Loading File ProcessTest.rb No such file to load -- win32ole
It would be great if this would work without the need for another file.
-
you need win32ole.so for that example.
... but you still need another file to access process identification (win32ole or win32api)
Advertisement