Page 1 of 1

Run Executable Inside Zeus Using Python

Posted: Mon Jun 18, 2012 5:04 am
by jussij

Code: Select all

#
#        Name: Process
#
#  Decription: Run a executable inside Zeus using Python and capture
#              the output.
#

import os
import zeus
import subprocess

def key_macro():
   #
   # http://docs.python.org/library/subprocess.html
   #

   # set the current directory
   os.chdir("c:/temp")

   # initialise the startup info to run hidden
   info = subprocess.STARTUPINFO()
   info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
   info.wShowWindow = subprocess.SW_HIDE

   # run a command and capture the output
   p = subprocess.Popen(["cmd.exe", "/k", "dir *.*"], stdout=subprocess.PIPE, startupinfo=info)
   result = p.stdout.read()
   p.wait()

   # display the output
   zeus.message_box(0, result, "Python Process Output")

key_macro() # run the macro